Renamed Name.getName() and FqName.getFqName() to asString()

This commit is contained in:
Evgeny Gerashchenko
2013-05-21 17:56:04 +04:00
parent de6d5a4a96
commit 43b9a9d434
140 changed files with 294 additions and 304 deletions
@@ -115,7 +115,7 @@ public abstract class AnnotationCodegen {
} }
Name keyName = entry.getKey().getName(); Name keyName = entry.getKey().getName();
genAnnotationValueArgument(annotationVisitor, valueArgument, keyName.getName()); genAnnotationValueArgument(annotationVisitor, valueArgument, keyName.asString());
} }
} }
@@ -152,7 +152,7 @@ public abstract class AnnotationCodegen {
if (call != null) { if (call != null) {
if (call.getResultingDescriptor() instanceof PropertyDescriptor) { if (call.getResultingDescriptor() instanceof PropertyDescriptor) {
PropertyDescriptor descriptor = (PropertyDescriptor) call.getResultingDescriptor(); PropertyDescriptor descriptor = (PropertyDescriptor) call.getResultingDescriptor();
annotationVisitor.visitEnum(keyName, typeMapper.mapType(descriptor).getDescriptor(), descriptor.getName().getName()); annotationVisitor.visitEnum(keyName, typeMapper.mapType(descriptor).getDescriptor(), descriptor.getName().asString());
return; return;
} }
} }
@@ -168,7 +168,7 @@ public abstract class AnnotationCodegen {
if (annotations != null) { if (annotations != null) {
for (AnnotationDescriptor annotation : annotations) { for (AnnotationDescriptor annotation : annotations) {
//noinspection ConstantConditions //noinspection ConstantConditions
if ("Intrinsic".equals(annotation.getType().getConstructor().getDeclarationDescriptor().getName().getName())) { if ("Intrinsic".equals(annotation.getType().getConstructor().getDeclarationDescriptor().getName().asString())) {
value = (String) annotation.getAllValueArguments().values().iterator().next().getValue(); value = (String) annotation.getAllValueArguments().values().iterator().next().getValue();
break; break;
} }
@@ -505,7 +505,7 @@ public class AsmUtil {
Type asmType = state.getTypeMapper().mapReturnType(type); Type asmType = state.getTypeMapper().mapReturnType(type);
if (asmType.getSort() == Type.OBJECT || asmType.getSort() == Type.ARRAY) { if (asmType.getSort() == Type.OBJECT || asmType.getSort() == Type.ARRAY) {
v.load(index, asmType); v.load(index, asmType);
v.visitLdcInsn(descriptor.getName().getName()); v.visitLdcInsn(descriptor.getName().asString());
v.invokestatic("jet/runtime/Intrinsics", "checkParameterIsNotNull", "(Ljava/lang/Object;Ljava/lang/String;)V"); v.invokestatic("jet/runtime/Intrinsics", "checkParameterIsNotNull", "(Ljava/lang/Object;Ljava/lang/String;)V");
} }
} }
@@ -546,8 +546,8 @@ public class AsmUtil {
Type asmType = state.getTypeMapper().mapReturnType(type); Type asmType = state.getTypeMapper().mapReturnType(type);
if (asmType.getSort() == Type.OBJECT || asmType.getSort() == Type.ARRAY) { if (asmType.getSort() == Type.OBJECT || asmType.getSort() == Type.ARRAY) {
v.dup(); v.dup();
v.visitLdcInsn(descriptor.getContainingDeclaration().getName().getName()); v.visitLdcInsn(descriptor.getContainingDeclaration().getName().asString());
v.visitLdcInsn(descriptor.getName().getName()); v.visitLdcInsn(descriptor.getName().asString());
v.invokestatic("jet/runtime/Intrinsics", assertMethodToCall, "(Ljava/lang/Object;Ljava/lang/String;Ljava/lang/String;)V"); v.invokestatic("jet/runtime/Intrinsics", assertMethodToCall, "(Ljava/lang/Object;Ljava/lang/String;Ljava/lang/String;)V");
} }
} }
@@ -178,7 +178,7 @@ public class ClosureCodegen extends GenerationStateAware {
return; return;
} }
MethodVisitor mv = cv.newMethod(fun, ACC_PUBLIC | ACC_BRIDGE, interfaceFunction.getName().getName(), MethodVisitor mv = cv.newMethod(fun, ACC_PUBLIC | ACC_BRIDGE, interfaceFunction.getName().asString(),
bridge.getDescriptor(), null, ArrayUtil.EMPTY_STRING_ARRAY); bridge.getDescriptor(), null, ArrayUtil.EMPTY_STRING_ARRAY);
if (state.getClassBuilderMode() == ClassBuilderMode.STUBS) { if (state.getClassBuilderMode() == ClassBuilderMode.STUBS) {
genStubCode(mv); genStubCode(mv);
@@ -203,7 +203,7 @@ public class ClosureCodegen extends GenerationStateAware {
count++; count++;
} }
iv.invokevirtual(name.getInternalName(), interfaceFunction.getName().getName(), delegate.getDescriptor()); iv.invokevirtual(name.getInternalName(), interfaceFunction.getName().asString(), delegate.getDescriptor());
StackValue.onStack(delegate.getReturnType()).put(bridge.getReturnType(), iv); StackValue.onStack(delegate.getReturnType()).put(bridge.getReturnType(), iv);
iv.areturn(bridge.getReturnType()); iv.areturn(bridge.getReturnType());
@@ -268,11 +268,11 @@ public class ClosureCodegen extends GenerationStateAware {
Type type = sharedVarType != null Type type = sharedVarType != null
? sharedVarType ? sharedVarType
: typeMapper.mapType((VariableDescriptor) descriptor); : typeMapper.mapType((VariableDescriptor) descriptor);
args.add(FieldInfo.createForHiddenField(ownerType, type, "$" + descriptor.getName().getName())); args.add(FieldInfo.createForHiddenField(ownerType, type, "$" + descriptor.getName().asString()));
} }
else if (isLocalNamedFun(descriptor)) { else if (isLocalNamedFun(descriptor)) {
JvmClassName className = classNameForAnonymousClass(bindingContext, (FunctionDescriptor) descriptor); JvmClassName className = classNameForAnonymousClass(bindingContext, (FunctionDescriptor) descriptor);
args.add(FieldInfo.createForHiddenField(ownerType, className.getAsmType(), "$" + descriptor.getName().getName())); args.add(FieldInfo.createForHiddenField(ownerType, className.getAsmType(), "$" + descriptor.getName().asString()));
} }
else if (descriptor instanceof FunctionDescriptor) { else if (descriptor instanceof FunctionDescriptor) {
assert captureReceiver != null; assert captureReceiver != null;
@@ -560,7 +560,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
@Override @Override
public void run() { public void run() {
myFrameMap.leave(parameterDescriptor); myFrameMap.leave(parameterDescriptor);
v.visitLocalVariable(parameterDescriptor.getName().getName(), v.visitLocalVariable(parameterDescriptor.getName().asString(),
asmTypeForParameter.getDescriptor(), null, asmTypeForParameter.getDescriptor(), null,
bodyStart, bodyEnd, bodyStart, bodyEnd,
loopParameterVar); loopParameterVar);
@@ -601,7 +601,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
@Override @Override
public void run() { public void run() {
myFrameMap.leave(componentDescriptor); myFrameMap.leave(componentDescriptor);
v.visitLocalVariable(componentDescriptor.getName().getName(), v.visitLocalVariable(componentDescriptor.getName().asString(),
componentAsmType.getDescriptor(), null, componentAsmType.getDescriptor(), null,
bodyStart, bodyEnd, bodyStart, bodyEnd,
componentVarIndex); componentVarIndex);
@@ -1414,7 +1414,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
v.store(index, OBJECT_TYPE); v.store(index, OBJECT_TYPE);
} }
} }
v.visitLocalVariable(variableDescriptor.getName().getName(), type.getDescriptor(), null, scopeStart, blockEnd, v.visitLocalVariable(variableDescriptor.getName().asString(), type.getDescriptor(), null, scopeStart, blockEnd,
index); index);
return null; return null;
} }
@@ -1628,7 +1628,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
ClassDescriptor containing = (ClassDescriptor) variableDescriptor.getContainingDeclaration().getContainingDeclaration(); ClassDescriptor containing = (ClassDescriptor) variableDescriptor.getContainingDeclaration().getContainingDeclaration();
assert containing != null; assert containing != null;
Type type = typeMapper.mapType(containing); Type type = typeMapper.mapType(containing);
return StackValue.field(type, JvmClassName.byType(type), variableDescriptor.getName().getName(), true); return StackValue.field(type, JvmClassName.byType(type), variableDescriptor.getName().asString(), true);
} }
else { else {
return StackValue.singleton(objectClassDescriptor, typeMapper); return StackValue.singleton(objectClassDescriptor, typeMapper);
@@ -2924,7 +2924,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
else { else {
DeclarationDescriptor cls = op.getContainingDeclaration(); DeclarationDescriptor cls = op.getContainingDeclaration();
CallableMethod callableMethod = (CallableMethod) callable; CallableMethod callableMethod = (CallableMethod) callable;
if (isPrimitiveNumberClassDescriptor(cls) || !(op.getName().getName().equals("inc") || op.getName().getName().equals("dec"))) { if (isPrimitiveNumberClassDescriptor(cls) || !(op.getName().asString().equals("inc") || op.getName().asString().equals("dec"))) {
return invokeOperation(expression, (FunctionDescriptor) op, callableMethod); return invokeOperation(expression, (FunctionDescriptor) op, callableMethod);
} }
else { else {
@@ -2981,14 +2981,14 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
if (op instanceof FunctionDescriptor) { if (op instanceof FunctionDescriptor) {
Type asmType = expressionType(expression); Type asmType = expressionType(expression);
DeclarationDescriptor cls = op.getContainingDeclaration(); DeclarationDescriptor cls = op.getContainingDeclaration();
if (op.getName().getName().equals("inc") || op.getName().getName().equals("dec")) { if (op.getName().asString().equals("inc") || op.getName().asString().equals("dec")) {
if (isPrimitiveNumberClassDescriptor(cls)) { if (isPrimitiveNumberClassDescriptor(cls)) {
receiver.put(receiver.type, v); receiver.put(receiver.type, v);
JetExpression operand = expression.getBaseExpression(); JetExpression operand = expression.getBaseExpression();
if (operand instanceof JetReferenceExpression) { if (operand instanceof JetReferenceExpression) {
int index = indexOfLocal((JetReferenceExpression) operand); int index = indexOfLocal((JetReferenceExpression) operand);
if (index >= 0 && isIntPrimitive(asmType)) { if (index >= 0 && isIntPrimitive(asmType)) {
int increment = op.getName().getName().equals("inc") ? 1 : -1; int increment = op.getName().asString().equals("inc") ? 1 : -1;
return StackValue.postIncrement(index, increment); return StackValue.postIncrement(index, increment);
} }
} }
@@ -3053,7 +3053,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
} }
private void generateIncrement(DeclarationDescriptor op, Type asmType, JetExpression operand, StackValue receiver) { private void generateIncrement(DeclarationDescriptor op, Type asmType, JetExpression operand, StackValue receiver) {
int increment = op.getName().getName().equals("inc") ? 1 : -1; int increment = op.getName().asString().equals("inc") ? 1 : -1;
if (operand instanceof JetReferenceExpression) { if (operand instanceof JetReferenceExpression) {
int index = indexOfLocal((JetReferenceExpression) operand); int index = indexOfLocal((JetReferenceExpression) operand);
if (index >= 0 && isIntPrimitive(asmType)) { if (index >= 0 && isIntPrimitive(asmType)) {
@@ -41,7 +41,7 @@ public class FieldInfo {
Type ownerType = typeMapper.mapType(ownerDescriptor.getDefaultType()); Type ownerType = typeMapper.mapType(ownerDescriptor.getDefaultType());
String fieldName = kind == ClassKind.ENUM_ENTRY String fieldName = kind == ClassKind.ENUM_ENTRY
? fieldClassDescriptor.getName().getName() ? fieldClassDescriptor.getName().asString()
: fieldClassDescriptor.getKind() == ClassKind.CLASS_OBJECT ? JvmAbi.CLASS_OBJECT_FIELD : JvmAbi.INSTANCE_FIELD; : fieldClassDescriptor.getKind() == ClassKind.CLASS_OBJECT ? JvmAbi.CLASS_OBJECT_FIELD : JvmAbi.INSTANCE_FIELD;
return new FieldInfo(ownerType, fieldType, fieldName, true); return new FieldInfo(ownerType, fieldType, fieldName, true);
} }
@@ -200,7 +200,7 @@ public class FunctionCodegen extends GenerationStateAware {
List<ValueParameterDescriptor> parameters = functionDescriptor.getValueParameters(); List<ValueParameterDescriptor> parameters = functionDescriptor.getValueParameters();
List<String> result = new ArrayList<String>(parameters.size()); List<String> result = new ArrayList<String>(parameters.size());
for (ValueParameterDescriptor parameter : parameters) { for (ValueParameterDescriptor parameter : parameters) {
result.add(parameter.getName().getName()); result.add(parameter.getName().asString());
} }
return result; return result;
} }
@@ -244,7 +244,7 @@ public class FunctionCodegen extends GenerationStateAware {
if (kind == JvmMethodParameterKind.VALUE) { if (kind == JvmMethodParameterKind.VALUE) {
ValueParameterDescriptor parameter = valueParameters.next(); ValueParameterDescriptor parameter = valueParameters.next();
Label divideLabel = labelsForSharedVars.get(parameter.getName()); Label divideLabel = labelsForSharedVars.get(parameter.getName());
parameterName = parameter.getName().getName(); parameterName = parameter.getName().asString();
if (divideLabel != null) { if (divideLabel != null) {
mv.visitLocalVariable(parameterName, type.getDescriptor(), null, methodBegin, divideLabel, shift); mv.visitLocalVariable(parameterName, type.getDescriptor(), null, methodBegin, divideLabel, shift);
@@ -377,7 +377,7 @@ public class FunctionCodegen extends GenerationStateAware {
ValueParameterDescriptor parameterDescriptor = null; ValueParameterDescriptor parameterDescriptor = null;
if (kind == JvmMethodParameterKind.VALUE) { if (kind == JvmMethodParameterKind.VALUE) {
parameterDescriptor = valueParameters.next(); parameterDescriptor = valueParameters.next();
parameterName = parameterDescriptor.getName().getName(); parameterName = parameterDescriptor.getName().asString();
} else if (kind == JvmMethodParameterKind.ENUM_NAME || kind == JvmMethodParameterKind.ENUM_ORDINAL) { } else if (kind == JvmMethodParameterKind.ENUM_NAME || kind == JvmMethodParameterKind.ENUM_ORDINAL) {
//we shouldn't generate annotations for invisible in runtime parameters otherwise we get bad RuntimeInvisibleParameterAnnotations error in javac //we shouldn't generate annotations for invisible in runtime parameters otherwise we get bad RuntimeInvisibleParameterAnnotations error in javac
continue; continue;
@@ -297,7 +297,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
innerClassInternalName = outerClassInternalName + JvmAbi.CLASS_OBJECT_SUFFIX; innerClassInternalName = outerClassInternalName + JvmAbi.CLASS_OBJECT_SUFFIX;
} }
else { else {
innerName = innerClass.getName().isSpecial() ? null : innerClass.getName().getName(); innerName = innerClass.getName().isSpecial() ? null : innerClass.getName().asString();
innerClassInternalName = getInternalNameForImpl(innerClass); innerClassInternalName = getInternalNameForImpl(innerClass);
} }
@@ -620,11 +620,11 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
boolean first = true; boolean first = true;
for (PropertyDescriptor propertyDescriptor : properties) { for (PropertyDescriptor propertyDescriptor : properties) {
if (first) { if (first) {
iv.aconst(descriptor.getName() + "(" + propertyDescriptor.getName().getName()+"="); iv.aconst(descriptor.getName() + "(" + propertyDescriptor.getName().asString()+"=");
first = false; first = false;
} }
else { else {
iv.aconst(", " + propertyDescriptor.getName().getName()+"="); iv.aconst(", " + propertyDescriptor.getName().asString()+"=");
} }
genInvokeAppendMethod(iv, JAVA_STRING_TYPE); genInvokeAppendMethod(iv, JAVA_STRING_TYPE);
@@ -821,7 +821,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
Type[] argTypes = method.getArgumentTypes(); Type[] argTypes = method.getArgumentTypes();
String owner = typeMapper.getOwner(original, OwnerKind.IMPLEMENTATION, isCallInsideSameModuleAsDeclared(original, context)).getInternalName(); String owner = typeMapper.getOwner(original, OwnerKind.IMPLEMENTATION, isCallInsideSameModuleAsDeclared(original, context)).getInternalName();
MethodVisitor mv = v.newMethod(null, ACC_SYNTHETIC | ACC_STATIC, bridge.getName().getName(), MethodVisitor mv = v.newMethod(null, ACC_SYNTHETIC | ACC_STATIC, bridge.getName().asString(),
method.getDescriptor(), null, null); method.getDescriptor(), null, null);
if (state.getClassBuilderMode() == ClassBuilderMode.STUBS) { if (state.getClassBuilderMode() == ClassBuilderMode.STUBS) {
genStubCode(mv); genStubCode(mv);
@@ -1015,7 +1015,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
Type type = typeMapper.mapType(descriptor); Type type = typeMapper.mapType(descriptor);
iv.load(0, classAsmType); iv.load(0, classAsmType);
iv.load(codegen.myFrameMap.getIndex(descriptor), type); iv.load(codegen.myFrameMap.getIndex(descriptor), type);
iv.putfield(classAsmType.getInternalName(), descriptor.getName().getName(), type.getDescriptor()); iv.putfield(classAsmType.getInternalName(), descriptor.getName().asString(), type.getDescriptor());
} }
curParam++; curParam++;
} }
@@ -1097,7 +1097,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
Boolean.TRUE.equals(bindingContext.get(BindingContext.BACKING_FIELD_REQUIRED, propertyDescriptor))) { Boolean.TRUE.equals(bindingContext.get(BindingContext.BACKING_FIELD_REQUIRED, propertyDescriptor))) {
// final property with backing field // final property with backing field
field = StackValue.field(typeMapper.mapType(propertyDescriptor.getType()), classname, field = StackValue.field(typeMapper.mapType(propertyDescriptor.getType()), classname,
propertyDescriptor.getName().getName(), false); propertyDescriptor.getName().asString(), false);
} }
else { else {
iv.load(0, classType); iv.load(0, classType);
@@ -148,7 +148,7 @@ public class PropertyCodegen extends GenerationStateAware {
modifiers |= ACC_VOLATILE; modifiers |= ACC_VOLATILE;
} }
Type type = typeMapper.mapType(propertyDescriptor); Type type = typeMapper.mapType(propertyDescriptor);
return v.newField(p, modifiers, propertyDescriptor.getName().getName(), type.getDescriptor(), null, value); return v.newField(p, modifiers, propertyDescriptor.getName().asString(), type.getDescriptor(), null, value);
} }
private void generateGetter(JetNamedDeclaration p, PropertyDescriptor propertyDescriptor, JetPropertyAccessor getter) { private void generateGetter(JetNamedDeclaration p, PropertyDescriptor propertyDescriptor, JetPropertyAccessor getter) {
@@ -248,7 +248,7 @@ public class PropertyCodegen extends GenerationStateAware {
iv.visitFieldInsn( iv.visitFieldInsn(
kind == OwnerKind.NAMESPACE ? GETSTATIC : GETFIELD, kind == OwnerKind.NAMESPACE ? GETSTATIC : GETFIELD,
typeMapper.getOwner(propertyDescriptor, kind, isCallInsideSameModuleAsDeclared(propertyDescriptor, context)).getInternalName(), typeMapper.getOwner(propertyDescriptor, kind, isCallInsideSameModuleAsDeclared(propertyDescriptor, context)).getInternalName(),
propertyDescriptor.getName().getName(), propertyDescriptor.getName().asString(),
type.getDescriptor()); type.getDescriptor());
iv.areturn(type); iv.areturn(type);
} }
@@ -265,7 +265,7 @@ public class PropertyCodegen extends GenerationStateAware {
iv.load(paramCode, type); iv.load(paramCode, type);
iv.visitFieldInsn(kind == OwnerKind.NAMESPACE ? PUTSTATIC : PUTFIELD, iv.visitFieldInsn(kind == OwnerKind.NAMESPACE ? PUTSTATIC : PUTFIELD,
typeMapper.getOwner(propertyDescriptor, kind, isCallInsideSameModuleAsDeclared(propertyDescriptor, context)).getInternalName(), typeMapper.getOwner(propertyDescriptor, kind, isCallInsideSameModuleAsDeclared(propertyDescriptor, context)).getInternalName(),
propertyDescriptor.getName().getName(), propertyDescriptor.getName().asString(),
type.getDescriptor()); type.getDescriptor());
iv.visitInsn(RETURN); iv.visitInsn(RETURN);
@@ -336,11 +336,11 @@ public class PropertyCodegen extends GenerationStateAware {
} }
public static String getterName(Name propertyName) { public static String getterName(Name propertyName) {
return JvmAbi.GETTER_PREFIX + StringUtil.capitalizeWithJavaBeanConvention(propertyName.getName()); return JvmAbi.GETTER_PREFIX + StringUtil.capitalizeWithJavaBeanConvention(propertyName.asString());
} }
public static String setterName(Name propertyName) { public static String setterName(Name propertyName) {
return JvmAbi.SETTER_PREFIX + StringUtil.capitalizeWithJavaBeanConvention(propertyName.getName()); return JvmAbi.SETTER_PREFIX + StringUtil.capitalizeWithJavaBeanConvention(propertyName.asString());
} }
public void genDelegate(PropertyDescriptor delegate, PropertyDescriptor overridden, StackValue field) { public void genDelegate(PropertyDescriptor delegate, PropertyDescriptor overridden, StackValue field) {
@@ -112,7 +112,7 @@ public class RangeCodegenUtil {
} }
public static boolean isOptimizableRangeTo(CallableDescriptor rangeTo) { public static boolean isOptimizableRangeTo(CallableDescriptor rangeTo) {
if ("rangeTo".equals(rangeTo.getName().getName())) { if ("rangeTo".equals(rangeTo.getName().asString())) {
if (isPrimitiveNumberClassDescriptor(rangeTo.getContainingDeclaration())) { if (isPrimitiveNumberClassDescriptor(rangeTo.getContainingDeclaration())) {
return true; return true;
} }
@@ -913,7 +913,7 @@ public abstract class StackValue {
} }
private String getPropertyName() { private String getPropertyName() {
return isDelegated ? JvmAbi.getPropertyDelegateName(descriptor.getName()) : descriptor.getName().getName(); return isDelegated ? JvmAbi.getPropertyDelegateName(descriptor.getName()) : descriptor.getName().asString();
} }
} }
@@ -227,7 +227,7 @@ class CodegenAnnotatingVisitor extends JetVisitorVoid {
private String getName(ClassDescriptor classDescriptor) { private String getName(ClassDescriptor classDescriptor) {
String base = peekFromStack(nameStack); String base = peekFromStack(nameStack);
return DescriptorUtils.isTopLevelDeclaration(classDescriptor) ? base.isEmpty() ? classDescriptor.getName() return DescriptorUtils.isTopLevelDeclaration(classDescriptor) ? base.isEmpty() ? classDescriptor.getName()
.getName() : base + '/' + classDescriptor.getName() : base + '$' + classDescriptor.getName(); .asString() : base + '/' + classDescriptor.getName() : base + '$' + classDescriptor.getName();
} }
@Override @Override
@@ -350,7 +350,7 @@ class CodegenAnnotatingVisitor extends JetVisitorVoid {
DeclarationDescriptor containingDeclaration = descriptor.getContainingDeclaration(); DeclarationDescriptor containingDeclaration = descriptor.getContainingDeclaration();
String peek = peekFromStack(nameStack); String peek = peekFromStack(nameStack);
String name = descriptor.getName().getName(); String name = descriptor.getName().asString();
if (containingDeclaration instanceof ClassDescriptor) { if (containingDeclaration instanceof ClassDescriptor) {
return peek + '$' + name; return peek + '$' + name;
} }
@@ -116,7 +116,7 @@ public final class PsiCodegenPredictor {
if (declaration instanceof JetNamedFunction) { if (declaration instanceof JetNamedFunction) {
if (parentDeclaration == null) { if (parentDeclaration == null) {
JvmClassName packageClass = addPackageClass(parentClassName); JvmClassName packageClass = addPackageClass(parentClassName);
return JvmClassName.byInternalName(packageClass.getInternalName() + "$" + name.getName()); return JvmClassName.byInternalName(packageClass.getInternalName() + "$" + name.asString());
} }
if (!(parentDeclaration instanceof JetClass || parentDeclaration instanceof JetObjectDeclaration)) { if (!(parentDeclaration instanceof JetClass || parentDeclaration instanceof JetObjectDeclaration)) {
@@ -128,16 +128,16 @@ public final class PsiCodegenPredictor {
// NOTE: looks like a bug - for class in getter of top level property class name will be $propertyName$ClassName but not // NOTE: looks like a bug - for class in getter of top level property class name will be $propertyName$ClassName but not
// namespace$propertyName$ClassName // namespace$propertyName$ClassName
if (declaration instanceof JetProperty) { if (declaration instanceof JetProperty) {
return JvmClassName.byInternalName(parentClassName.getInternalName() + "$" + name.getName()); return JvmClassName.byInternalName(parentClassName.getInternalName() + "$" + name.asString());
} }
if (fqName.isRoot()) { if (fqName.isRoot()) {
return JvmClassName.byInternalName(name.getName()); return JvmClassName.byInternalName(name.asString());
} }
return JvmClassName.byInternalName(parentDeclaration == null ? return JvmClassName.byInternalName(parentDeclaration == null ?
parentClassName.getInternalName() + "/" + name.getName() : parentClassName.getInternalName() + "/" + name.asString() :
parentClassName.getInternalName() + "$" + name.getName()); parentClassName.getInternalName() + "$" + name.asString());
} }
return null; return null;
@@ -241,7 +241,7 @@ public class IntrinsicMethods {
for (AnnotationDescriptor annotation : annotations) { for (AnnotationDescriptor annotation : annotations) {
ClassifierDescriptor classifierDescriptor = annotation.getType().getConstructor().getDeclarationDescriptor(); ClassifierDescriptor classifierDescriptor = annotation.getType().getConstructor().getDeclarationDescriptor();
assert classifierDescriptor != null; assert classifierDescriptor != null;
if ("Intrinsic".equals(classifierDescriptor.getName().getName())) { if ("Intrinsic".equals(classifierDescriptor.getName().asString())) {
String value = (String) annotation.getAllValueArguments().values().iterator().next().getValue(); String value = (String) annotation.getAllValueArguments().values().iterator().next().getValue();
intrinsicMethod = namedMethods.get(value); intrinsicMethod = namedMethods.get(value);
if (intrinsicMethod != null) { if (intrinsicMethod != null) {
@@ -51,7 +51,7 @@ public class StaticField implements IntrinsicMethod {
StackValue receiver, StackValue receiver,
@NotNull GenerationState state @NotNull GenerationState state
) { ) {
v.getstatic(JvmClassName.byFqNameWithoutInnerClasses(ownerClass).getInternalName(), propertyName.getName(), expectedType.getDescriptor()); v.getstatic(JvmClassName.byFqNameWithoutInnerClasses(ownerClass).getInternalName(), propertyName.asString(), expectedType.getDescriptor());
return StackValue.onStack(expectedType); return StackValue.onStack(expectedType);
} }
} }
@@ -272,8 +272,8 @@ public class BothSignatureWriter {
} }
public void writeTypeVariable(Name name, boolean nullable, Type asmType) { public void writeTypeVariable(Name name, boolean nullable, Type asmType) {
signatureVisitor().visitTypeVariable(name.getName()); signatureVisitor().visitTypeVariable(name.asString());
jetSignatureWriter.visitTypeVariable(name.getName(), nullable); jetSignatureWriter.visitTypeVariable(name.asString(), nullable);
generic = true; generic = true;
writeAsmType0(asmType); writeAsmType0(asmType);
} }
@@ -578,7 +578,7 @@ public class JetTypeMapper extends BindingTraceAware {
@NotNull @NotNull
public JvmMethodSignature mapSignature(@NotNull FunctionDescriptor f, boolean needGenericSignature, @NotNull OwnerKind kind) { public JvmMethodSignature mapSignature(@NotNull FunctionDescriptor f, boolean needGenericSignature, @NotNull OwnerKind kind) {
String name = f.getName().getName(); String name = f.getName().asString();
if (f instanceof PropertyAccessorDescriptor) { if (f instanceof PropertyAccessorDescriptor) {
boolean isGetter = f instanceof PropertyGetterDescriptor; boolean isGetter = f instanceof PropertyGetterDescriptor;
name = getPropertyAccessorName(((PropertyAccessorDescriptor) f).getCorrespondingProperty(), isGetter); name = getPropertyAccessorName(((PropertyAccessorDescriptor) f).getCorrespondingProperty(), isGetter);
@@ -588,7 +588,7 @@ public class JetTypeMapper extends BindingTraceAware {
@NotNull @NotNull
public JvmMethodSignature mapSignature(@NotNull Name functionName, @NotNull FunctionDescriptor f) { public JvmMethodSignature mapSignature(@NotNull Name functionName, @NotNull FunctionDescriptor f) {
return mapSignature(functionName.getName(), f, false, OwnerKind.IMPLEMENTATION); return mapSignature(functionName.asString(), f, false, OwnerKind.IMPLEMENTATION);
} }
@NotNull @NotNull
@@ -675,7 +675,7 @@ public class JetTypeMapper extends BindingTraceAware {
} }
private void writeFormalTypeParameter(TypeParameterDescriptor typeParameterDescriptor, BothSignatureWriter signatureVisitor) { private void writeFormalTypeParameter(TypeParameterDescriptor typeParameterDescriptor, BothSignatureWriter signatureVisitor) {
signatureVisitor.writeFormalTypeParameter(typeParameterDescriptor.getName().getName(), typeParameterDescriptor.getVariance(), signatureVisitor.writeFormalTypeParameter(typeParameterDescriptor.getName().asString(), typeParameterDescriptor.getVariance(),
typeParameterDescriptor.isReified()); typeParameterDescriptor.isReified());
classBound: classBound:
@@ -730,7 +730,7 @@ public class JetTypeMapper extends BindingTraceAware {
DeclarationDescriptor parentDescriptor = descriptor.getContainingDeclaration(); DeclarationDescriptor parentDescriptor = descriptor.getContainingDeclaration();
boolean isAnnotation = parentDescriptor instanceof ClassDescriptor && boolean isAnnotation = parentDescriptor instanceof ClassDescriptor &&
((ClassDescriptor) parentDescriptor).getKind() == ClassKind.ANNOTATION_CLASS; ((ClassDescriptor) parentDescriptor).getKind() == ClassKind.ANNOTATION_CLASS;
return isAnnotation ? descriptor.getName().getName() : return isAnnotation ? descriptor.getName().asString() :
isGetter ? PropertyCodegen.getterName(descriptor.getName()) : PropertyCodegen.setterName(descriptor.getName()); isGetter ? PropertyCodegen.getterName(descriptor.getName()) : PropertyCodegen.setterName(descriptor.getName());
} }
@@ -109,7 +109,7 @@ public final class AnalyzerWithCompilerReport {
if (!incompletes.isEmpty()) { if (!incompletes.isEmpty()) {
StringBuilder message = new StringBuilder("The following classes have incomplete hierarchies:\n"); StringBuilder message = new StringBuilder("The following classes have incomplete hierarchies:\n");
for (ClassDescriptor incomplete : incompletes) { for (ClassDescriptor incomplete : incompletes) {
String fqName = DescriptorUtils.getFQName(incomplete).getFqName(); String fqName = DescriptorUtils.getFQName(incomplete).asString();
message.append(" ").append(fqName).append("\n"); message.append(" ").append(fqName).append("\n");
} }
messageCollectorWrapper.report(CompilerMessageSeverity.ERROR, message.toString(), CompilerMessageLocation.NO_LOCATION); messageCollectorWrapper.report(CompilerMessageSeverity.ERROR, message.toString(), CompilerMessageLocation.NO_LOCATION);
@@ -203,7 +203,7 @@ public class CompileEnvironmentUtil {
mainAttributes.putValue("Manifest-Version", "1.0"); mainAttributes.putValue("Manifest-Version", "1.0");
mainAttributes.putValue("Created-By", "JetBrains Kotlin"); mainAttributes.putValue("Created-By", "JetBrains Kotlin");
if (mainClass != null) { if (mainClass != null) {
mainAttributes.putValue("Main-Class", mainClass.getFqName()); mainAttributes.putValue("Main-Class", mainClass.asString());
} }
JarOutputStream stream = new JarOutputStream(fos, manifest); JarOutputStream stream = new JarOutputStream(fos, manifest);
for (String file : factory.files()) { for (String file : factory.files()) {
@@ -236,7 +236,7 @@ public class ReplInterpreter {
} }
try { try {
Class<?> scriptClass = classLoader.loadClass(scriptClassName.getFqName().getFqName()); Class<?> scriptClass = classLoader.loadClass(scriptClassName.getFqName().asString());
Class<?>[] constructorParams = new Class<?>[earlierLines.size()]; Class<?>[] constructorParams = new Class<?>[earlierLines.size()];
Object[] constructorArgs = new Object[earlierLines.size()]; Object[] constructorArgs = new Object[earlierLines.size()];
@@ -140,7 +140,7 @@ public final class DescriptorResolverUtils {
public static FqNameUnsafe getFqNameForClassObject(@NotNull PsiClass psiClass) { public static FqNameUnsafe getFqNameForClassObject(@NotNull PsiClass psiClass) {
String psiClassQualifiedName = psiClass.getQualifiedName(); String psiClassQualifiedName = psiClass.getQualifiedName();
assert psiClassQualifiedName != null : "Reading java class with no qualified name"; assert psiClassQualifiedName != null : "Reading java class with no qualified name";
return new FqNameUnsafe(psiClassQualifiedName + "." + getClassObjectName(psiClass.getName()).getName()); return new FqNameUnsafe(psiClassQualifiedName + "." + getClassObjectName(psiClass.getName()).asString());
} }
@NotNull @NotNull
@@ -65,7 +65,7 @@ public class JavaToKotlinClassMap extends JavaToKotlinClassMapBuilder implements
PrimitiveType primitiveType = jvmPrimitiveType.getPrimitiveType(); PrimitiveType primitiveType = jvmPrimitiveType.getPrimitiveType();
primitiveTypesMap.put(jvmPrimitiveType.getName(), KotlinBuiltIns.getInstance().getPrimitiveJetType(primitiveType)); primitiveTypesMap.put(jvmPrimitiveType.getName(), KotlinBuiltIns.getInstance().getPrimitiveJetType(primitiveType));
primitiveTypesMap.put("[" + jvmPrimitiveType.getName(), KotlinBuiltIns.getInstance().getPrimitiveArrayJetType(primitiveType)); primitiveTypesMap.put("[" + jvmPrimitiveType.getName(), KotlinBuiltIns.getInstance().getPrimitiveArrayJetType(primitiveType));
primitiveTypesMap.put(jvmPrimitiveType.getWrapper().getFqName().getFqName(), KotlinBuiltIns.getInstance().getNullablePrimitiveJetType( primitiveTypesMap.put(jvmPrimitiveType.getWrapper().getFqName().asString(), KotlinBuiltIns.getInstance().getNullablePrimitiveJetType(
primitiveType)); primitiveType));
} }
primitiveTypesMap.put("void", KotlinBuiltIns.getInstance().getUnitType()); primitiveTypesMap.put("void", KotlinBuiltIns.getInstance().getUnitType());
@@ -91,7 +91,7 @@ public class JavaToKotlinClassMap extends JavaToKotlinClassMapBuilder implements
@Nullable @Nullable
public AnnotationDescriptor mapToAnnotationClass(@NotNull FqName fqName) { public AnnotationDescriptor mapToAnnotationClass(@NotNull FqName fqName) {
ClassDescriptor classDescriptor = classDescriptorMap.get(fqName); ClassDescriptor classDescriptor = classDescriptorMap.get(fqName);
if (classDescriptor != null && fqName.getFqName().equals(CommonClassNames.JAVA_LANG_DEPRECATED)) { if (classDescriptor != null && fqName.asString().equals(CommonClassNames.JAVA_LANG_DEPRECATED)) {
return DescriptorResolverUtils.getAnnotationDescriptorForJavaLangDeprecated(classDescriptor); return DescriptorResolverUtils.getAnnotationDescriptorForJavaLangDeprecated(classDescriptor);
} }
return null; return null;
@@ -184,7 +184,7 @@ public class JavaTypeTransformer {
" in " + classType.getPresentableText() + "\n PsiClass: \n" + psiClass.getText()); " in " + classType.getPresentableText() + "\n PsiClass: \n" + psiClass.getText());
for (TypeParameterDescriptor parameter : parameters) { for (TypeParameterDescriptor parameter : parameters) {
arguments.add(new TypeProjection(ErrorUtils.createErrorType(parameter.getName().getName()))); arguments.add(new TypeProjection(ErrorUtils.createErrorType(parameter.getName().asString())));
} }
} }
else { else {
@@ -275,10 +275,10 @@ public class JavaTypeTransformer {
if (!signatureTypeUsages.contains(originalTypeUsage)) { if (!signatureTypeUsages.contains(originalTypeUsage)) {
return originalTypeUsage; return originalTypeUsage;
} }
if (JavaAnnotationResolver.findAnnotationWithExternal(owner, JvmAbi.JETBRAINS_MUTABLE_ANNOTATION.getFqName().getFqName()) != null) { if (JavaAnnotationResolver.findAnnotationWithExternal(owner, JvmAbi.JETBRAINS_MUTABLE_ANNOTATION.getFqName().asString()) != null) {
return TypeUsage.MEMBER_SIGNATURE_COVARIANT; return TypeUsage.MEMBER_SIGNATURE_COVARIANT;
} }
if (JavaAnnotationResolver.findAnnotationWithExternal(owner, JvmAbi.JETBRAINS_READONLY_ANNOTATION.getFqName().getFqName()) != null) { if (JavaAnnotationResolver.findAnnotationWithExternal(owner, JvmAbi.JETBRAINS_READONLY_ANNOTATION.getFqName().asString()) != null) {
return TypeUsage.MEMBER_SIGNATURE_CONTRAVARIANT; return TypeUsage.MEMBER_SIGNATURE_CONTRAVARIANT;
} }
return originalTypeUsage; return originalTypeUsage;
@@ -86,7 +86,7 @@ public abstract class JetTypeJetSignatureReader extends JetSignatureExceptionsAd
public void visitClassType(String signatureName, boolean nullable, boolean forceReal) { public void visitClassType(String signatureName, boolean nullable, boolean forceReal) {
FqName fqName = JvmClassName.bySignatureName(signatureName).getFqName(); FqName fqName = JvmClassName.bySignatureName(signatureName).getFqName();
enterClass(resolveClassDescriptorByFqName(fqName, forceReal), fqName.getFqName(), nullable); enterClass(resolveClassDescriptorByFqName(fqName, forceReal), fqName.asString(), nullable);
} }
private void enterClass(@Nullable ClassDescriptor classDescriptor, @NotNull String className, boolean nullable) { private void enterClass(@Nullable ClassDescriptor classDescriptor, @NotNull String className, boolean nullable) {
@@ -17,8 +17,6 @@
package org.jetbrains.jet.lang.resolve.java; package org.jetbrains.jet.lang.resolve.java;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.jet.lang.descriptors.ClassDescriptor;
import org.jetbrains.jet.lang.descriptors.ClassKind;
import org.jetbrains.jet.lang.resolve.name.FqName; import org.jetbrains.jet.lang.resolve.name.FqName;
import org.jetbrains.jet.lang.resolve.name.Name; import org.jetbrains.jet.lang.resolve.name.Name;
@@ -58,7 +56,7 @@ public class JvmAbi {
} }
public static String getPropertyDelegateName(@NotNull Name name) { public static String getPropertyDelegateName(@NotNull Name name) {
return name.getName() + DELEGATED_PROPERTY_NAME_POSTFIX; return name.asString() + DELEGATED_PROPERTY_NAME_POSTFIX;
} }
private JvmAbi() { private JvmAbi() {
@@ -91,7 +91,7 @@ public class JvmClassName {
List<String> innerClassNames = Lists.newArrayList(); List<String> innerClassNames = Lists.newArrayList();
while (descriptor.getContainingDeclaration() instanceof ClassDescriptor) { while (descriptor.getContainingDeclaration() instanceof ClassDescriptor) {
innerClassNames.add(descriptor.getName().getName()); innerClassNames.add(descriptor.getName().asString());
descriptor = descriptor.getContainingDeclaration(); descriptor = descriptor.getContainingDeclaration();
assert descriptor != null; assert descriptor != null;
} }
@@ -101,7 +101,7 @@ public class JvmClassName {
@NotNull @NotNull
private static String fqNameToInternalName(@NotNull FqName fqName) { private static String fqNameToInternalName(@NotNull FqName fqName) {
return fqName.getFqName().replace('.', '/'); return fqName.asString().replace('.', '/');
} }
@NotNull @NotNull
@@ -122,6 +122,6 @@ public class KotlinToJavaTypesMap extends JavaToKotlinClassMapBuilder {
public boolean isForceReal(@NotNull JvmClassName className) { public boolean isForceReal(@NotNull JvmClassName className) {
return JvmPrimitiveType.getByWrapperClass(className) != null return JvmPrimitiveType.getByWrapperClass(className) != null
|| mappedTypeNames.contains(className.getFqName().getFqName()); || mappedTypeNames.contains(className.getFqName().asString());
} }
} }
@@ -32,7 +32,7 @@ public class PackageClassUtils {
if (packageFQN.isRoot()) { if (packageFQN.isRoot()) {
return DEFAULT_PACKAGE; return DEFAULT_PACKAGE;
} }
return StringUtil.capitalize(packageFQN.shortName().getName()) + "Package"; return StringUtil.capitalize(packageFQN.shortName().asString()) + "Package";
} }
public static FqName getPackageClassFqName(@NotNull FqName packageFQN) { public static FqName getPackageClassFqName(@NotNull FqName packageFQN) {
@@ -86,7 +86,7 @@ public class PsiClassFinderImpl implements PsiClassFinder {
@Override @Override
@Nullable @Nullable
public PsiClass findPsiClass(@NotNull FqName qualifiedName, @NotNull RuntimeClassesHandleMode runtimeClassesHandleMode) { public PsiClass findPsiClass(@NotNull FqName qualifiedName, @NotNull RuntimeClassesHandleMode runtimeClassesHandleMode) {
PsiClass original = javaFacade.findClass(qualifiedName.getFqName(), javaSearchScope); PsiClass original = javaFacade.findClass(qualifiedName.asString(), javaSearchScope);
if (original != null) { if (original != null) {
String classQualifiedName = original.getQualifiedName(); String classQualifiedName = original.getQualifiedName();
@@ -106,7 +106,7 @@ public class PsiClassFinderImpl implements PsiClassFinder {
if (KotlinBuiltIns.BUILT_INS_PACKAGE_FQ_NAME.equals(qualifiedName.parent())) { if (KotlinBuiltIns.BUILT_INS_PACKAGE_FQ_NAME.equals(qualifiedName.parent())) {
PsiAnnotation assertInvisibleAnnotation = JavaAnnotationResolver.findOwnAnnotation( PsiAnnotation assertInvisibleAnnotation = JavaAnnotationResolver.findOwnAnnotation(
original, JvmStdlibNames.ASSERT_INVISIBLE_IN_RESOLVER.getFqName().getFqName()); original, JvmStdlibNames.ASSERT_INVISIBLE_IN_RESOLVER.getFqName().asString());
if (assertInvisibleAnnotation != null) { if (assertInvisibleAnnotation != null) {
switch (runtimeClassesHandleMode) { switch (runtimeClassesHandleMode) {
@@ -131,7 +131,7 @@ public class PsiClassFinderImpl implements PsiClassFinder {
@Override @Override
@Nullable @Nullable
public PsiPackage findPsiPackage(@NotNull FqName qualifiedName) { public PsiPackage findPsiPackage(@NotNull FqName qualifiedName) {
return javaFacade.findPackage(qualifiedName.getFqName()); return javaFacade.findPackage(qualifiedName.asString());
} }
@NotNull @NotNull
@@ -60,7 +60,7 @@ public class TypeVariableResolverFromTypeDescriptors implements TypeVariableReso
@NotNull DeclarationDescriptor owner, @NotNull DeclarationDescriptor owner,
@NotNull String context) { @NotNull String context) {
for (TypeParameterDescriptor typeParameter : typeParameters) { for (TypeParameterDescriptor typeParameter : typeParameters) {
if (typeParameter.getName().getName().equals(name)) { if (typeParameter.getName().asString().equals(name)) {
return typeParameter; return typeParameter;
} }
} }
@@ -254,7 +254,7 @@ public class SignaturesPropagationData {
public int compare(FunctionDescriptor fun1, FunctionDescriptor fun2) { public int compare(FunctionDescriptor fun1, FunctionDescriptor fun2) {
FqNameUnsafe fqName1 = getFQName(fun1.getContainingDeclaration()); FqNameUnsafe fqName1 = getFQName(fun1.getContainingDeclaration());
FqNameUnsafe fqName2 = getFQName(fun2.getContainingDeclaration()); FqNameUnsafe fqName2 = getFQName(fun2.getContainingDeclaration());
return fqName1.getFqName().compareTo(fqName2.getFqName()); return fqName1.asString().compareTo(fqName2.asString());
} }
}); });
return superFunctions; return superFunctions;
@@ -99,14 +99,14 @@ public class TypeTransformingVisitor extends JetVisitor<JetType, Void> {
} }
private JetType visitCommonType(@NotNull ClassDescriptor classDescriptor, @NotNull JetTypeElement type) { private JetType visitCommonType(@NotNull ClassDescriptor classDescriptor, @NotNull JetTypeElement type) {
return visitCommonType(DescriptorUtils.getFQName(classDescriptor).toSafe().getFqName(), type); return visitCommonType(DescriptorUtils.getFQName(classDescriptor).toSafe().asString(), type);
} }
private JetType visitCommonType(@NotNull String qualifiedName, @NotNull JetTypeElement type) { private JetType visitCommonType(@NotNull String qualifiedName, @NotNull JetTypeElement type) {
TypeConstructor originalTypeConstructor = originalType.getConstructor(); TypeConstructor originalTypeConstructor = originalType.getConstructor();
ClassifierDescriptor declarationDescriptor = originalTypeConstructor.getDeclarationDescriptor(); ClassifierDescriptor declarationDescriptor = originalTypeConstructor.getDeclarationDescriptor();
assert declarationDescriptor != null; assert declarationDescriptor != null;
String fqName = DescriptorUtils.getFQName(declarationDescriptor).toSafe().getFqName(); String fqName = DescriptorUtils.getFQName(declarationDescriptor).toSafe().asString();
ClassDescriptor classFromLibrary = getAutoTypeAnalogWithinBuiltins(qualifiedName); ClassDescriptor classFromLibrary = getAutoTypeAnalogWithinBuiltins(qualifiedName);
if (!isSameName(qualifiedName, fqName) && classFromLibrary == null) { if (!isSameName(qualifiedName, fqName) && classFromLibrary == null) {
throw new AlternativeSignatureMismatchException("Alternative signature type mismatch, expected: %s, actual: %s", qualifiedName, fqName); throw new AlternativeSignatureMismatchException("Alternative signature type mismatch, expected: %s, actual: %s", qualifiedName, fqName);
@@ -212,7 +212,7 @@ public class TypeTransformingVisitor extends JetVisitor<JetType, Void> {
Collection<ClassDescriptor> descriptors = Collection<ClassDescriptor> descriptors =
JavaToKotlinClassMap.getInstance().mapPlatformClass(JvmClassName.byType(javaAnalog).getFqName()); JavaToKotlinClassMap.getInstance().mapPlatformClass(JvmClassName.byType(javaAnalog).getFqName());
for (ClassDescriptor descriptor : descriptors) { for (ClassDescriptor descriptor : descriptors) {
String fqName = DescriptorUtils.getFQName(descriptor).getFqName(); String fqName = DescriptorUtils.getFQName(descriptor).asString();
if (isSameName(qualifiedName, fqName)) { if (isSameName(qualifiedName, fqName)) {
return descriptor; return descriptor;
} }
@@ -54,7 +54,7 @@ public class JetClassAnnotation extends PsiAnnotationWithAbiVersion {
@NotNull @NotNull
public static JetClassAnnotation get(PsiClass psiClass) { public static JetClassAnnotation get(PsiClass psiClass) {
PsiAnnotation annotation = JavaAnnotationResolver.findOwnAnnotation(psiClass, PsiAnnotation annotation = JavaAnnotationResolver.findOwnAnnotation(psiClass,
JvmStdlibNames.JET_CLASS.getFqName().getFqName()); JvmStdlibNames.JET_CLASS.getFqName().asString());
return annotation != null ? new JetClassAnnotation(annotation) : NULL_ANNOTATION; return annotation != null ? new JetClassAnnotation(annotation) : NULL_ANNOTATION;
} }
} }
@@ -38,7 +38,7 @@ public class JetClassObjectAnnotation extends PsiAnnotationWithAbiVersion {
@NotNull @NotNull
public static JetClassObjectAnnotation get(@NotNull PsiClass psiClass) { public static JetClassObjectAnnotation get(@NotNull PsiClass psiClass) {
PsiAnnotation annotation = PsiAnnotation annotation =
JavaAnnotationResolver.findOwnAnnotation(psiClass, JvmStdlibNames.JET_CLASS_OBJECT.getFqName().getFqName()); JavaAnnotationResolver.findOwnAnnotation(psiClass, JvmStdlibNames.JET_CLASS_OBJECT.getFqName().asString());
return annotation != null ? new JetClassObjectAnnotation(annotation) : NULL_ANNOTATION; return annotation != null ? new JetClassObjectAnnotation(annotation) : NULL_ANNOTATION;
} }
} }
@@ -48,7 +48,7 @@ public class JetConstructorAnnotation extends PsiAnnotationWithFlags {
public static JetConstructorAnnotation get(PsiMethod constructor) { public static JetConstructorAnnotation get(PsiMethod constructor) {
PsiAnnotation annotation = PsiAnnotation annotation =
JavaAnnotationResolver.findOwnAnnotation(constructor, JvmStdlibNames.JET_CONSTRUCTOR.getFqName().getFqName()); JavaAnnotationResolver.findOwnAnnotation(constructor, JvmStdlibNames.JET_CONSTRUCTOR.getFqName().asString());
return annotation != null ? new JetConstructorAnnotation(annotation) : NULL_ANNOTATION; return annotation != null ? new JetConstructorAnnotation(annotation) : NULL_ANNOTATION;
} }
} }
@@ -69,7 +69,7 @@ public class JetMethodAnnotation extends PsiAnnotationWithFlags {
public static JetMethodAnnotation get(PsiMethod psiMethod) { public static JetMethodAnnotation get(PsiMethod psiMethod) {
PsiAnnotation annotation = PsiAnnotation annotation =
JavaAnnotationResolver.findOwnAnnotation(psiMethod, JvmStdlibNames.JET_METHOD.getFqName().getFqName()); JavaAnnotationResolver.findOwnAnnotation(psiMethod, JvmStdlibNames.JET_METHOD.getFqName().asString());
return annotation != null ? new JetMethodAnnotation(annotation) : NULL_ANNOTATION; return annotation != null ? new JetMethodAnnotation(annotation) : NULL_ANNOTATION;
} }
} }
@@ -36,7 +36,7 @@ public class JetPackageClassAnnotation extends PsiAnnotationWithAbiVersion {
@NotNull @NotNull
public static JetPackageClassAnnotation get(PsiClass psiClass) { public static JetPackageClassAnnotation get(PsiClass psiClass) {
PsiAnnotation annotation = JavaAnnotationResolver.findOwnAnnotation(psiClass, PsiAnnotation annotation = JavaAnnotationResolver.findOwnAnnotation(psiClass,
JvmStdlibNames.JET_PACKAGE_CLASS.getFqName().getFqName()); JvmStdlibNames.JET_PACKAGE_CLASS.getFqName().asString());
return annotation != null ? new JetPackageClassAnnotation(annotation) : NULL_ANNOTATION; return annotation != null ? new JetPackageClassAnnotation(annotation) : NULL_ANNOTATION;
} }
} }
@@ -40,7 +40,7 @@ public class JetTypeParameterAnnotation extends PsiAnnotationWrapper {
@NotNull @NotNull
public static JetTypeParameterAnnotation get(@NotNull PsiParameter psiParameter) { public static JetTypeParameterAnnotation get(@NotNull PsiParameter psiParameter) {
PsiAnnotation annotation = PsiAnnotation annotation =
JavaAnnotationResolver.findOwnAnnotation(psiParameter, JvmStdlibNames.JET_TYPE_PARAMETER.getFqName().getFqName()); JavaAnnotationResolver.findOwnAnnotation(psiParameter, JvmStdlibNames.JET_TYPE_PARAMETER.getFqName().asString());
return annotation != null ? new JetTypeParameterAnnotation(annotation) : NULL_ANNOTATION; return annotation != null ? new JetTypeParameterAnnotation(annotation) : NULL_ANNOTATION;
} }
} }
@@ -77,7 +77,7 @@ public class JetValueParameterAnnotation extends PsiAnnotationWrapper {
public static JetValueParameterAnnotation get(PsiParameter psiParameter) { public static JetValueParameterAnnotation get(PsiParameter psiParameter) {
PsiAnnotation annotation = PsiAnnotation annotation =
JavaAnnotationResolver.findOwnAnnotation(psiParameter, JvmStdlibNames.JET_VALUE_PARAMETER.getFqName().getFqName()); JavaAnnotationResolver.findOwnAnnotation(psiParameter, JvmStdlibNames.JET_VALUE_PARAMETER.getFqName().asString());
return annotation != null ? new JetValueParameterAnnotation(annotation) : NULL_ANNOTATION; return annotation != null ? new JetValueParameterAnnotation(annotation) : NULL_ANNOTATION;
} }
} }
@@ -50,7 +50,7 @@ public class KotlinSignatureAnnotation extends PsiAnnotationWrapper {
@NotNull @NotNull
public static KotlinSignatureAnnotation get(PsiModifierListOwner psiModifierListOwner) { public static KotlinSignatureAnnotation get(PsiModifierListOwner psiModifierListOwner) {
PsiAnnotation annotation = PsiAnnotation annotation =
JavaAnnotationResolver.findAnnotationWithExternal(psiModifierListOwner, JvmStdlibNames.KOTLIN_SIGNATURE.getFqName().getFqName()); JavaAnnotationResolver.findAnnotationWithExternal(psiModifierListOwner, JvmStdlibNames.KOTLIN_SIGNATURE.getFqName().asString());
return annotation != null ? new KotlinSignatureAnnotation(annotation) : NULL_ANNOTATION; return annotation != null ? new KotlinSignatureAnnotation(annotation) : NULL_ANNOTATION;
} }
} }
@@ -413,7 +413,7 @@ public final class MembersCache {
return null; return null;
} }
String qualifiedName = psiClass.getQualifiedName(); String qualifiedName = psiClass.getQualifiedName();
if (qualifiedName == null || qualifiedName.startsWith(KotlinBuiltIns.BUILT_INS_PACKAGE_FQ_NAME.getFqName() + ".")) { if (qualifiedName == null || qualifiedName.startsWith(KotlinBuiltIns.BUILT_INS_PACKAGE_FQ_NAME.asString() + ".")) {
return null; return null;
} }
if (!psiClass.isInterface() || psiClass.isAnnotationType()) { if (!psiClass.isInterface() || psiClass.isAnnotationType()) {
@@ -84,7 +84,7 @@ public final class JavaAnnotationResolver {
} }
// Don't process internal jet annotations and jetbrains NotNull annotations // Don't process internal jet annotations and jetbrains NotNull annotations
if (qname.startsWith("jet.runtime.typeinfo.") || qname.equals(JvmAbi.JETBRAINS_NOT_NULL_ANNOTATION.getFqName().getFqName())) { if (qname.startsWith("jet.runtime.typeinfo.") || qname.equals(JvmAbi.JETBRAINS_NOT_NULL_ANNOTATION.getFqName().asString())) {
return null; return null;
} }
@@ -131,7 +131,7 @@ public final class JavaClassObjectResolver {
ClassDescriptorFromJvmBytecode classObjectDescriptor = ClassDescriptorFromJvmBytecode classObjectDescriptor =
new ClassDescriptorFromJvmBytecode(containing, ClassKind.CLASS_OBJECT, false); new ClassDescriptorFromJvmBytecode(containing, ClassKind.CLASS_OBJECT, false);
ClassPsiDeclarationProvider data = semanticServices.getPsiDeclarationProviderFactory().createSyntheticClassObjectClassData(psiClass); ClassPsiDeclarationProvider data = semanticServices.getPsiDeclarationProviderFactory().createSyntheticClassObjectClassData(psiClass);
setUpClassObjectDescriptor(classObjectDescriptor, containing, fqName, data, getClassObjectName(containing.getName().getName())); setUpClassObjectDescriptor(classObjectDescriptor, containing, fqName, data, getClassObjectName(containing.getName().asString()));
return classObjectDescriptor; return classObjectDescriptor;
} }
@@ -44,7 +44,6 @@ import org.jetbrains.jet.lang.resolve.name.FqNameBase;
import org.jetbrains.jet.lang.resolve.name.FqNameUnsafe; import org.jetbrains.jet.lang.resolve.name.FqNameUnsafe;
import org.jetbrains.jet.lang.resolve.name.Name; import org.jetbrains.jet.lang.resolve.name.Name;
import org.jetbrains.jet.lang.types.JetType; import org.jetbrains.jet.lang.types.JetType;
import org.jetbrains.jet.lang.types.TypeSubstitutor;
import org.jetbrains.jet.lang.types.TypeUtils; import org.jetbrains.jet.lang.types.TypeUtils;
import javax.inject.Inject; import javax.inject.Inject;
@@ -203,7 +202,7 @@ public final class JavaClassResolver {
private static boolean isTraitImplementation(@NotNull FqName qualifiedName) { private static boolean isTraitImplementation(@NotNull FqName qualifiedName) {
// TODO: only if -$$TImpl class is created by Kotlin // TODO: only if -$$TImpl class is created by Kotlin
return qualifiedName.getFqName().endsWith(JvmAbi.TRAIT_IMPL_SUFFIX); return qualifiedName.asString().endsWith(JvmAbi.TRAIT_IMPL_SUFFIX);
} }
@NotNull @NotNull
@@ -295,7 +294,7 @@ public final class JavaClassResolver {
String containerQualifiedName = methodContainer.getQualifiedName(); String containerQualifiedName = methodContainer.getQualifiedName();
assert containerQualifiedName != null : "qualified name is null for " + psiClass; assert containerQualifiedName != null : "qualified name is null for " + psiClass;
if (DescriptorUtils.getFQName(samInterface).getFqName().equals(containerQualifiedName)) { if (DescriptorUtils.getFQName(samInterface).asString().equals(containerQualifiedName)) {
SimpleFunctionDescriptor abstractMethod = SimpleFunctionDescriptor abstractMethod =
functionResolver.resolveFunctionMutely(new PsiMethodWrapper(samInterfaceMethod), samInterface); functionResolver.resolveFunctionMutely(new PsiMethodWrapper(samInterfaceMethod), samInterface);
assert abstractMethod != null : "couldn't resolve method " + samInterfaceMethod; assert abstractMethod != null : "couldn't resolve method " + samInterfaceMethod;
@@ -378,7 +377,7 @@ public final class JavaClassResolver {
private static FqNameUnsafe javaClassToKotlinFqName(@NotNull FqName rawFqName) { private static FqNameUnsafe javaClassToKotlinFqName(@NotNull FqName rawFqName) {
List<Name> correctedSegments = new ArrayList<Name>(); List<Name> correctedSegments = new ArrayList<Name>();
for (Name segment : rawFqName.pathSegments()) { for (Name segment : rawFqName.pathSegments()) {
if (JvmAbi.CLASS_OBJECT_CLASS_NAME.equals(segment.getName())) { if (JvmAbi.CLASS_OBJECT_CLASS_NAME.equals(segment.asString())) {
assert !correctedSegments.isEmpty(); assert !correctedSegments.isEmpty();
Name previous = correctedSegments.get(correctedSegments.size() - 1); Name previous = correctedSegments.get(correctedSegments.size() - 1);
correctedSegments.add(DescriptorUtils.getClassObjectName(previous)); correctedSegments.add(DescriptorUtils.getClassObjectName(previous));
@@ -125,7 +125,7 @@ public final class JavaFunctionResolver {
// TODO: unless maybe class explicitly extends Object // TODO: unless maybe class explicitly extends Object
assert containingClass != null; assert containingClass != null;
String ownerClassName = containingClass.getQualifiedName(); String ownerClassName = containingClass.getQualifiedName();
if (DescriptorResolverUtils.OBJECT_FQ_NAME.getFqName().equals(ownerClassName)) { if (DescriptorResolverUtils.OBJECT_FQ_NAME.asString().equals(ownerClassName)) {
return null; return null;
} }
} }
@@ -439,7 +439,7 @@ public final class JavaFunctionResolver {
transformedType = typeTransformer.transformToType(returnType, typeUsage, typeVariableResolver); transformedType = typeTransformer.transformToType(returnType, typeUsage, typeVariableResolver);
} }
if (JavaAnnotationResolver.findAnnotationWithExternal(method.getPsiMethod(), JvmAbi.JETBRAINS_NOT_NULL_ANNOTATION.getFqName().getFqName()) != if (JavaAnnotationResolver.findAnnotationWithExternal(method.getPsiMethod(), JvmAbi.JETBRAINS_NOT_NULL_ANNOTATION.getFqName().asString()) !=
null) { null) {
return TypeUtils.makeNullableAsSpecified(transformedType, false); return TypeUtils.makeNullableAsSpecified(transformedType, false);
} }
@@ -392,7 +392,7 @@ public final class JavaPropertyResolver {
boolean hasNotNullAnnotation = JavaAnnotationResolver.findAnnotationWithExternal( boolean hasNotNullAnnotation = JavaAnnotationResolver.findAnnotationWithExternal(
characteristicMember.getType().getPsiNotNullOwner(), characteristicMember.getType().getPsiNotNullOwner(),
JvmAbi.JETBRAINS_NOT_NULL_ANNOTATION.getFqName().getFqName()) != null; JvmAbi.JETBRAINS_NOT_NULL_ANNOTATION.getFqName().asString()) != null;
if (hasNotNullAnnotation || members.isStaticFinalField()) { if (hasNotNullAnnotation || members.isStaticFinalField()) {
propertyType = TypeUtils.makeNotNullable(propertyType); propertyType = TypeUtils.makeNotNullable(propertyType);
@@ -90,7 +90,7 @@ public final class JavaValueParameterResolver {
else { else {
JetType transformedType; JetType transformedType;
if (JavaAnnotationResolver.findAnnotationWithExternal(parameter.getPsiParameter(), JvmAbi.JETBRAINS_NOT_NULL_ANNOTATION.getFqName().getFqName()) != if (JavaAnnotationResolver.findAnnotationWithExternal(parameter.getPsiParameter(), JvmAbi.JETBRAINS_NOT_NULL_ANNOTATION.getFqName().asString()) !=
null) { null) {
transformedType = TypeUtils.makeNullableAsSpecified(outType, false); transformedType = TypeUtils.makeNullableAsSpecified(outType, false);
} }
@@ -73,7 +73,7 @@ public class ClassDescriptorImpl extends DeclarationDescriptorNonRootImpl implem
@Nullable ConstructorDescriptor primaryConstructor, @Nullable ConstructorDescriptor primaryConstructor,
boolean isInner boolean isInner
) { ) {
this.typeConstructor = new TypeConstructorImpl(this, getAnnotations(), sealed, getName().getName(), typeParameters, supertypes); this.typeConstructor = new TypeConstructorImpl(this, getAnnotations(), sealed, getName().asString(), typeParameters, supertypes);
this.memberDeclarations = memberDeclarations; this.memberDeclarations = memberDeclarations;
this.constructors = constructors; this.constructors = constructors;
this.primaryConstructor = primaryConstructor; this.primaryConstructor = primaryConstructor;
@@ -109,7 +109,7 @@ public abstract class MutableClassDescriptorLite extends ClassDescriptorBase {
this, this,
Collections.<AnnotationDescriptor>emptyList(), // TODO : pass annotations from the class? Collections.<AnnotationDescriptor>emptyList(), // TODO : pass annotations from the class?
!getModality().isOverridable(), !getModality().isOverridable(),
getName().getName(), getName().asString(),
typeParameters, typeParameters,
supertypes); supertypes);
} }
@@ -91,7 +91,7 @@ public class TypeParameterDescriptorImpl extends DeclarationDescriptorNonRootImp
this, this,
annotations, annotations,
false, false,
name.getName(), name.asString(),
Collections.<TypeParameterDescriptor>emptyList(), Collections.<TypeParameterDescriptor>emptyList(),
upperBounds); upperBounds);
} }
@@ -64,7 +64,7 @@ public class Renderers {
@Override @Override
public String render(@NotNull Object element) { public String render(@NotNull Object element) {
if (element instanceof Named) { if (element instanceof Named) {
return ((Named) element).getName().getName(); return ((Named) element).getName().asString();
} }
return element.toString(); return element.toString();
} }
@@ -299,7 +299,7 @@ public class Renderers {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
int index = 0; int index = 0;
for (ClassDescriptor descriptor : descriptors) { for (ClassDescriptor descriptor : descriptors) {
sb.append(DescriptorUtils.getFQName(descriptor).getFqName()); sb.append(DescriptorUtils.getFQName(descriptor).asString());
index++; index++;
if (index <= descriptors.size() - 2) { if (index <= descriptors.size() - 2) {
sb.append(", "); sb.append(", ");
@@ -199,7 +199,7 @@ public class JetClass extends JetTypeParameterListOwnerStub<PsiJetClassStub> imp
PsiJetClassStub stub = getStub(); PsiJetClassStub stub = getStub();
if (stub != null) { if (stub != null) {
FqName fqName = stub.getFqName(); FqName fqName = stub.getFqName();
return fqName == null ? null : fqName.getFqName(); return fqName == null ? null : fqName.asString();
} }
List<String> parts = new ArrayList<String>(); List<String> parts = new ArrayList<String>();
@@ -228,7 +228,7 @@ public class JetPsiFactory {
Name alias = importPath.getAlias(); Name alias = importPath.getAlias();
if (alias != null) { if (alias != null) {
importDirectiveBuilder.append(" as ").append(alias.getName()); importDirectiveBuilder.append(" as ").append(alias.asString());
} }
JetFile namespace = createFile(project, importDirectiveBuilder.toString()); JetFile namespace = createFile(project, importDirectiveBuilder.toString());
@@ -408,7 +408,7 @@ public class JetPsiUtil {
return false; return false;
} }
return KotlinBuiltIns.getInstance().getUnit().getName().getName().equals(typeReference.getText()); return KotlinBuiltIns.getInstance().getUnit().getName().asString().equals(typeReference.getText());
} }
public static boolean isSafeCall(@NotNull Call call) { public static boolean isSafeCall(@NotNull Call call) {
@@ -694,7 +694,7 @@ public class JetPsiUtil {
public static boolean checkVariableDeclarationInBlock(@NotNull JetBlockExpression block, @NotNull String varName) { public static boolean checkVariableDeclarationInBlock(@NotNull JetBlockExpression block, @NotNull String varName) {
for (JetElement element : block.getStatements()) { for (JetElement element : block.getStatements()) {
if (element instanceof JetVariableDeclaration) { if (element instanceof JetVariableDeclaration) {
if (((JetVariableDeclaration) element).getNameAsSafeName().getName().equals(varName)) { if (((JetVariableDeclaration) element).getNameAsSafeName().asString().equals(varName)) {
return true; return true;
} }
} }
@@ -50,7 +50,7 @@ public class JetAnnotationElementType extends JetStubElementType<PsiJetAnnotatio
@Override @Override
public PsiJetAnnotationStub createStub(@NotNull JetAnnotationEntry psi, StubElement parentStub) { public PsiJetAnnotationStub createStub(@NotNull JetAnnotationEntry psi, StubElement parentStub) {
Name shortName = JetPsiUtil.getShortName(psi); Name shortName = JetPsiUtil.getShortName(psi);
String resultName = shortName != null ? shortName.getName() : psi.getText(); String resultName = shortName != null ? shortName.asString() : psi.getText();
return new PsiJetAnnotationStubImpl(parentStub, JetStubElementTypes.ANNOTATION_ENTRY, resultName); return new PsiJetAnnotationStubImpl(parentStub, JetStubElementTypes.ANNOTATION_ENTRY, resultName);
} }
@@ -54,7 +54,7 @@ public class JetClassElementType extends JetStubElementType<PsiJetClassStub, Jet
public PsiJetClassStub createStub(@NotNull JetClass psi, StubElement parentStub) { public PsiJetClassStub createStub(@NotNull JetClass psi, StubElement parentStub) {
FqName fqName = JetPsiUtil.getFQName(psi); FqName fqName = JetPsiUtil.getFQName(psi);
boolean isEnumEntry = psi instanceof JetEnumEntry; boolean isEnumEntry = psi instanceof JetEnumEntry;
return new PsiJetClassStubImpl(getStubType(isEnumEntry), parentStub, fqName != null ? fqName.getFqName() : null, psi.getName(), return new PsiJetClassStubImpl(getStubType(isEnumEntry), parentStub, fqName != null ? fqName.asString() : null, psi.getName(),
psi.getSuperNames(), psi.isTrait(), psi.isEnum(), isEnumEntry, psi.isAnnotation(), psi.isInner()); psi.getSuperNames(), psi.isTrait(), psi.isEnum(), isEnumEntry, psi.isAnnotation(), psi.isInner());
} }
@@ -62,7 +62,7 @@ public class JetClassElementType extends JetStubElementType<PsiJetClassStub, Jet
public void serialize(PsiJetClassStub stub, StubOutputStream dataStream) throws IOException { public void serialize(PsiJetClassStub stub, StubOutputStream dataStream) throws IOException {
dataStream.writeName(stub.getName()); dataStream.writeName(stub.getName());
FqName fqName = stub.getFqName(); FqName fqName = stub.getFqName();
dataStream.writeName(fqName == null ? null : fqName.getFqName()); dataStream.writeName(fqName == null ? null : fqName.asString());
dataStream.writeBoolean(stub.isTrait()); dataStream.writeBoolean(stub.isTrait());
dataStream.writeBoolean(stub.isEnumClass()); dataStream.writeBoolean(stub.isEnumClass());
dataStream.writeBoolean(stub.isEnumEntry()); dataStream.writeBoolean(stub.isEnumEntry());
@@ -93,11 +93,11 @@ public class AnnotationResolver {
ConstructorDescriptor constructor = (ConstructorDescriptor)descriptor; ConstructorDescriptor constructor = (ConstructorDescriptor)descriptor;
ClassDescriptor classDescriptor = constructor.getContainingDeclaration(); ClassDescriptor classDescriptor = constructor.getContainingDeclaration();
if (classDescriptor.getKind() != ClassKind.ANNOTATION_CLASS) { if (classDescriptor.getKind() != ClassKind.ANNOTATION_CLASS) {
trace.report(Errors.NOT_AN_ANNOTATION_CLASS.on(entryElement, classDescriptor.getName().getName())); trace.report(Errors.NOT_AN_ANNOTATION_CLASS.on(entryElement, classDescriptor.getName().asString()));
} }
} }
else { else {
trace.report(Errors.NOT_AN_ANNOTATION_CLASS.on(entryElement, descriptor.getName().getName())); trace.report(Errors.NOT_AN_ANNOTATION_CLASS.on(entryElement, descriptor.getName().asString()));
} }
} }
JetType annotationType = results.getResultingDescriptor().getReturnType(); JetType annotationType = results.getResultingDescriptor().getReturnType();
@@ -313,7 +313,7 @@ public class DeclarationResolver {
for (PsiElement declaration : getDeclarationsByDescriptor(declarationDescriptor)) { for (PsiElement declaration : getDeclarationsByDescriptor(declarationDescriptor)) {
assert declaration != null : "Null declaration for descriptor: " + declarationDescriptor + " " + assert declaration != null : "Null declaration for descriptor: " + declarationDescriptor + " " +
(declarationDescriptor != null ? DescriptorRenderer.TEXT.render(declarationDescriptor) : ""); (declarationDescriptor != null ? DescriptorRenderer.TEXT.render(declarationDescriptor) : "");
trace.report(REDECLARATION.on(declaration, declarationDescriptor.getName().getName())); trace.report(REDECLARATION.on(declaration, declarationDescriptor.getName().asString()));
} }
} }
} }
@@ -402,7 +402,7 @@ public class DeclarationResolver {
} }
} }
for (Pair<PsiElement, Name> redeclaration : redeclarations) { for (Pair<PsiElement, Name> redeclaration : redeclarations) {
trace.report(REDECLARATION.on(redeclaration.getFirst(), redeclaration.getSecond().getName())); trace.report(REDECLARATION.on(redeclaration.getFirst(), redeclaration.getSecond().asString()));
} }
} }
@@ -280,7 +280,7 @@ public class DeclarationsChecker {
boolean inEnum = classDescriptor.getKind() == ClassKind.ENUM_CLASS; boolean inEnum = classDescriptor.getKind() == ClassKind.ENUM_CLASS;
boolean inAbstractClass = classDescriptor.getModality() == Modality.ABSTRACT; boolean inAbstractClass = classDescriptor.getModality() == Modality.ABSTRACT;
if (hasAbstractModifier && !inAbstractClass && !inEnum) { if (hasAbstractModifier && !inAbstractClass && !inEnum) {
trace.report(ABSTRACT_FUNCTION_IN_NON_ABSTRACT_CLASS.on(function, functionDescriptor.getName().getName(), classDescriptor)); trace.report(ABSTRACT_FUNCTION_IN_NON_ABSTRACT_CLASS.on(function, functionDescriptor.getName().asString(), classDescriptor));
} }
if (hasAbstractModifier && inTrait) { if (hasAbstractModifier && inTrait) {
trace.report(ABSTRACT_MODIFIER_IN_TRAIT.on(function)); trace.report(ABSTRACT_MODIFIER_IN_TRAIT.on(function));
@@ -363,7 +363,7 @@ public class DescriptorUtils {
@NotNull @NotNull
public static Name getClassObjectName(@NotNull Name className) { public static Name getClassObjectName(@NotNull Name className) {
return getClassObjectName(className.getName()); return getClassObjectName(className.asString());
} }
@NotNull @NotNull
@@ -405,7 +405,7 @@ public class DescriptorUtils {
String typeSuffix = rendererForTypesIfNecessary == null String typeSuffix = rendererForTypesIfNecessary == null
? "" ? ""
: ": " + rendererForTypesIfNecessary.renderType(value.getType(KotlinBuiltIns.getInstance())); : ": " + rendererForTypesIfNecessary.renderType(value.getType(KotlinBuiltIns.getInstance()));
resultList.add(entry.getKey().getName().getName() + " = " + value.toString() + typeSuffix); resultList.add(entry.getKey().getName().asString() + " = " + value.toString() + typeSuffix);
} }
Collections.sort(resultList); Collections.sort(resultList);
return resultList; return resultList;
@@ -536,14 +536,14 @@ public class DescriptorUtils {
public static boolean isEnumValueOfMethod(@NotNull FunctionDescriptor functionDescriptor) { public static boolean isEnumValueOfMethod(@NotNull FunctionDescriptor functionDescriptor) {
List<ValueParameterDescriptor> methodTypeParameters = functionDescriptor.getValueParameters(); List<ValueParameterDescriptor> methodTypeParameters = functionDescriptor.getValueParameters();
JetType nullableString = TypeUtils.makeNullable(KotlinBuiltIns.getInstance().getStringType()); JetType nullableString = TypeUtils.makeNullable(KotlinBuiltIns.getInstance().getStringType());
return "valueOf".equals(functionDescriptor.getName().getName()) return "valueOf".equals(functionDescriptor.getName().asString())
&& methodTypeParameters.size() == 1 && methodTypeParameters.size() == 1
&& JetTypeChecker.INSTANCE.isSubtypeOf(methodTypeParameters.get(0).getType(), nullableString); && JetTypeChecker.INSTANCE.isSubtypeOf(methodTypeParameters.get(0).getType(), nullableString);
} }
public static boolean isEnumValuesMethod(@NotNull FunctionDescriptor functionDescriptor) { public static boolean isEnumValuesMethod(@NotNull FunctionDescriptor functionDescriptor) {
List<ValueParameterDescriptor> methodTypeParameters = functionDescriptor.getValueParameters(); List<ValueParameterDescriptor> methodTypeParameters = functionDescriptor.getValueParameters();
return "values".equals(functionDescriptor.getName().getName()) return "values".equals(functionDescriptor.getName().asString())
&& methodTypeParameters.isEmpty(); && methodTypeParameters.isEmpty();
} }
@@ -50,12 +50,12 @@ public final class ImportPath {
} }
public String getPathStr() { public String getPathStr() {
return fqName.getFqName() + (isAllUnder ? ".*" : ""); return fqName.asString() + (isAllUnder ? ".*" : "");
} }
@Override @Override
public String toString() { public String toString() {
return getPathStr() + (alias != null ? " as " + alias.getName() : ""); return getPathStr() + (alias != null ? " as " + alias.asString() : "");
} }
@NotNull @NotNull
@@ -75,7 +75,7 @@ public class OverloadResolver {
} }
Key(NamespaceDescriptor namespaceDescriptor, Name name) { Key(NamespaceDescriptor namespaceDescriptor, Name name) {
this(DescriptorUtils.getFQName(namespaceDescriptor).getFqName(), name); this(DescriptorUtils.getFQName(namespaceDescriptor).asString(), name);
} }
public String getNamespace() { public String getNamespace() {
@@ -149,7 +149,7 @@ public class OverloadResolver {
} }
if (jetClass instanceof JetObjectDeclaration) { if (jetClass instanceof JetObjectDeclaration) {
// must be class object // must be class object
name = classDescriptor.getContainingDeclaration().getName().getName(); name = classDescriptor.getContainingDeclaration().getName().asString();
return "class object " + name; return "class object " + name;
} }
// safe // safe
@@ -223,7 +223,7 @@ public class OverloadResolver {
CallableMemberDescriptor memberDescriptor = redeclaration.getSecond(); CallableMemberDescriptor memberDescriptor = redeclaration.getSecond();
JetDeclaration jetDeclaration = redeclaration.getFirst(); JetDeclaration jetDeclaration = redeclaration.getFirst();
if (memberDescriptor instanceof PropertyDescriptor) { if (memberDescriptor instanceof PropertyDescriptor) {
trace.report(Errors.REDECLARATION.on(jetDeclaration, memberDescriptor.getName().getName())); trace.report(Errors.REDECLARATION.on(jetDeclaration, memberDescriptor.getName().asString()));
} }
else { else {
trace.report(Errors.CONFLICTING_OVERLOADS.on(jetDeclaration, memberDescriptor, functionContainer)); trace.report(Errors.CONFLICTING_OVERLOADS.on(jetDeclaration, memberDescriptor, functionContainer));
@@ -155,7 +155,7 @@ public class OverrideResolver {
public void conflict(@NotNull CallableMemberDescriptor fromSuper, @NotNull CallableMemberDescriptor fromCurrent) { public void conflict(@NotNull CallableMemberDescriptor fromSuper, @NotNull CallableMemberDescriptor fromCurrent) {
JetDeclaration declaration = (JetDeclaration) BindingContextUtils JetDeclaration declaration = (JetDeclaration) BindingContextUtils
.descriptorToDeclaration(trace.getBindingContext(), fromCurrent); .descriptorToDeclaration(trace.getBindingContext(), fromCurrent);
trace.report(Errors.CONFLICTING_OVERLOADS.on(declaration, fromCurrent, fromCurrent.getContainingDeclaration().getName().getName())); trace.report(Errors.CONFLICTING_OVERLOADS.on(declaration, fromCurrent, fromCurrent.getContainingDeclaration().getName().asString()));
} }
}); });
} }
@@ -586,7 +586,7 @@ public class OverrideResolver {
private void checkOverrideForMember(@NotNull final CallableMemberDescriptor declared) { private void checkOverrideForMember(@NotNull final CallableMemberDescriptor declared) {
if (declared.getKind() == CallableMemberDescriptor.Kind.SYNTHESIZED) { if (declared.getKind() == CallableMemberDescriptor.Kind.SYNTHESIZED) {
// TODO: this should be replaced soon by a framework of synthesized member generation tools // TODO: this should be replaced soon by a framework of synthesized member generation tools
if (declared.getName().getName().startsWith(DescriptorResolver.COMPONENT_FUNCTION_NAME_PREFIX)) { if (declared.getName().asString().startsWith(DescriptorResolver.COMPONENT_FUNCTION_NAME_PREFIX)) {
checkOverrideForComponentFunction(declared); checkOverrideForComponentFunction(declared);
} }
return; return;
@@ -39,7 +39,7 @@ public class TraceBasedRedeclarationHandler implements RedeclarationHandler {
private void report(DeclarationDescriptor descriptor) { private void report(DeclarationDescriptor descriptor) {
PsiElement firstElement = BindingContextUtils.descriptorToDeclaration(trace.getBindingContext(), descriptor); PsiElement firstElement = BindingContextUtils.descriptorToDeclaration(trace.getBindingContext(), descriptor);
if (firstElement != null) { if (firstElement != null) {
trace.report(REDECLARATION.on(firstElement, descriptor.getName().getName())); trace.report(REDECLARATION.on(firstElement, descriptor.getName().asString()));
} }
else { else {
throw new IllegalStateException("No declaration found for " + descriptor); throw new IllegalStateException("No declaration found for " + descriptor);
@@ -342,7 +342,7 @@ public class TypeResolver {
assert size != 0 : "No projections possible for a nilary type constructor" + constructor; assert size != 0 : "No projections possible for a nilary type constructor" + constructor;
ClassifierDescriptor declarationDescriptor = constructor.getDeclarationDescriptor(); ClassifierDescriptor declarationDescriptor = constructor.getDeclarationDescriptor();
assert declarationDescriptor != null : "No declaration descriptor for type constructor " + constructor; assert declarationDescriptor != null : "No declaration descriptor for type constructor " + constructor;
String name = declarationDescriptor.getName().getName(); String name = declarationDescriptor.getName().asString();
return TypeUtils.getTypeNameAndStarProjectionsString(name, size); return TypeUtils.getTypeNameAndStarProjectionsString(name, size);
} }
@@ -51,7 +51,6 @@ import org.jetbrains.jet.lexer.JetTokens;
import javax.inject.Inject; import javax.inject.Inject;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.EnumSet;
import java.util.List; import java.util.List;
import static org.jetbrains.jet.lang.descriptors.ReceiverParameterDescriptor.NO_RECEIVER_PARAMETER; import static org.jetbrains.jet.lang.descriptors.ReceiverParameterDescriptor.NO_RECEIVER_PARAMETER;
@@ -100,7 +99,7 @@ public class CallResolver {
Name referencedName = nameExpression.getReferencedNameAsName(); Name referencedName = nameExpression.getReferencedNameAsName();
List<CallableDescriptorCollector<? extends VariableDescriptor>> callableDescriptorCollectors = Lists.newArrayList(); List<CallableDescriptorCollector<? extends VariableDescriptor>> callableDescriptorCollectors = Lists.newArrayList();
if (nameExpression.getReferencedNameElementType() == JetTokens.FIELD_IDENTIFIER) { if (nameExpression.getReferencedNameElementType() == JetTokens.FIELD_IDENTIFIER) {
referencedName = Name.identifier(referencedName.getName().substring(1)); referencedName = Name.identifier(referencedName.asString().substring(1));
callableDescriptorCollectors.add(CallableDescriptorCollectors.PROPERTIES); callableDescriptorCollectors.add(CallableDescriptorCollectors.PROPERTIES);
} }
else { else {
@@ -178,7 +178,7 @@ public class TracingStrategyImpl implements TracingStrategy {
JetExpression left = binaryExpression.getLeft(); JetExpression left = binaryExpression.getLeft();
JetExpression right = binaryExpression.getRight(); JetExpression right = binaryExpression.getRight();
if (left != null && right != null) { if (left != null && right != null) {
trace.report(UNSAFE_INFIX_CALL.on(reference, left.getText(), operationString.getName(), right.getText())); trace.report(UNSAFE_INFIX_CALL.on(reference, left.getText(), operationString.asString(), right.getText()));
} }
} }
else { else {
@@ -124,7 +124,7 @@ public class LazyClassMemberScope extends AbstractLazyMemberScope<LazyClassDescr
fromCurrent); fromCurrent);
assert declaration != null : "fromCurrent can not be a fake override"; assert declaration != null : "fromCurrent can not be a fake override";
trace.report(Errors.CONFLICTING_OVERLOADS trace.report(Errors.CONFLICTING_OVERLOADS
.on(declaration, fromCurrent, fromCurrent.getContainingDeclaration().getName().getName())); .on(declaration, fromCurrent, fromCurrent.getContainingDeclaration().getName().asString()));
} }
} }
); );
@@ -59,7 +59,7 @@ public class FqName extends FqNameBase {
private void validateFqName() { private void validateFqName() {
if (!isValidAfterUnsafeCheck(fqName.getFqName())) { if (!isValidAfterUnsafeCheck(fqName.asString())) {
throw new IllegalArgumentException("incorrect fq name: " + fqName); throw new IllegalArgumentException("incorrect fq name: " + fqName);
} }
} }
@@ -71,8 +71,8 @@ public class FqName extends FqNameBase {
@Override @Override
@NotNull @NotNull
public String getFqName() { public String asString() {
return fqName.getFqName(); return fqName.asString();
} }
@NotNull @NotNull
@@ -27,7 +27,7 @@ public abstract class FqNameBase {
} }
@NotNull @NotNull
protected abstract String getFqName(); protected abstract String asString();
@NotNull @NotNull
private FqNameUnsafe toFqNameUnsafe() { private FqNameUnsafe toFqNameUnsafe() {
@@ -51,6 +51,6 @@ public abstract class FqNameBase {
} }
public final boolean equalsTo(@NotNull String that) { public final boolean equalsTo(@NotNull String that) {
return getFqName().equals(that); return asString().equals(that);
} }
} }
@@ -85,7 +85,7 @@ public class FqNameUnsafe extends FqNameBase {
@NotNull @NotNull
public String getFqName() { public String asString() {
return fqName; return fqName;
} }
@@ -93,7 +93,7 @@ public class FqNameUnsafe extends FqNameBase {
if (safe != null) { if (safe != null) {
return true; return true;
} }
return FqName.isValidAfterUnsafeCheck(getFqName()); return FqName.isValidAfterUnsafeCheck(asString());
} }
@NotNull @NotNull
@@ -128,10 +128,10 @@ public class FqNameUnsafe extends FqNameBase {
public FqNameUnsafe child(@NotNull Name name) { public FqNameUnsafe child(@NotNull Name name) {
String childFqName; String childFqName;
if (isRoot()) { if (isRoot()) {
childFqName = name.getName(); childFqName = name.asString();
} }
else { else {
childFqName = fqName + "." + name.getName(); childFqName = fqName + "." + name.asString();
} }
return new FqNameUnsafe(childFqName, this, name); return new FqNameUnsafe(childFqName, this, name);
} }
@@ -210,7 +210,7 @@ public class FqNameUnsafe extends FqNameBase {
} }
Name firstSegment = Name.guess(fqName.substring(0, pos)); Name firstSegment = Name.guess(fqName.substring(0, pos));
FqNameUnsafe last = new FqNameUnsafe(firstSegment.getName(), FqName.ROOT.toUnsafe(), firstSegment); FqNameUnsafe last = new FqNameUnsafe(firstSegment.asString(), FqName.ROOT.toUnsafe(), firstSegment);
callback.segment(firstSegment, last); callback.segment(firstSegment, last);
while (true) { while (true) {
@@ -254,13 +254,13 @@ public class FqNameUnsafe extends FqNameBase {
@NotNull @NotNull
public static FqNameUnsafe topLevel(@NotNull Name shortName) { public static FqNameUnsafe topLevel(@NotNull Name shortName) {
return new FqNameUnsafe(shortName.getName(), FqName.ROOT.toUnsafe(), shortName); return new FqNameUnsafe(shortName.asString(), FqName.ROOT.toUnsafe(), shortName);
} }
@Override @Override
public String toString() { public String toString() {
return isRoot() ? ROOT_NAME.getName() : fqName; return isRoot() ? ROOT_NAME.asString() : fqName;
} }
@Override @Override
@@ -29,7 +29,7 @@ public final class Name implements Comparable<Name> {
} }
@NotNull @NotNull
public String getName() { public String asString() {
return name; return name;
} }
@@ -38,7 +38,7 @@ public final class Name implements Comparable<Name> {
if (special) { if (special) {
throw new IllegalStateException("not identifier: " + this); throw new IllegalStateException("not identifier: " + this);
} }
return getName(); return asString();
} }
public boolean isSpecial() { public boolean isSpecial() {
@@ -176,7 +176,7 @@ public class WritableScopeImpl extends WritableScopeWithImports {
checkMayWrite(); checkMayWrite();
Map<LabelName, List<DeclarationDescriptor>> labelsToDescriptors = getLabelsToDescriptors(); Map<LabelName, List<DeclarationDescriptor>> labelsToDescriptors = getLabelsToDescriptors();
LabelName name = new LabelName(descriptor.getName().getName()); LabelName name = new LabelName(descriptor.getName().asString());
List<DeclarationDescriptor> declarationDescriptors = labelsToDescriptors.get(name); List<DeclarationDescriptor> declarationDescriptors = labelsToDescriptors.get(name);
if (declarationDescriptors == null) { if (declarationDescriptors == null) {
declarationDescriptors = new ArrayList<DeclarationDescriptor>(); declarationDescriptors = new ArrayList<DeclarationDescriptor>();
@@ -481,7 +481,7 @@ public class WritableScopeImpl extends WritableScopeWithImports {
public PropertyDescriptor getPropertyByFieldReference(@NotNull Name fieldName) { public PropertyDescriptor getPropertyByFieldReference(@NotNull Name fieldName) {
checkMayRead(); checkMayRead();
if (!fieldName.getName().startsWith("$")) { if (!fieldName.asString().startsWith("$")) {
throw new IllegalStateException(); throw new IllegalStateException();
} }
@@ -792,13 +792,13 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
if (operationType == JetTokens.PLUSPLUS || operationType == JetTokens.MINUSMINUS) { if (operationType == JetTokens.PLUSPLUS || operationType == JetTokens.MINUSMINUS) {
assert returnType != null : "returnType is null for " + resolutionResults.getResultingDescriptor(); assert returnType != null : "returnType is null for " + resolutionResults.getResultingDescriptor();
if (JetTypeChecker.INSTANCE.isSubtypeOf(returnType, KotlinBuiltIns.getInstance().getUnitType())) { if (JetTypeChecker.INSTANCE.isSubtypeOf(returnType, KotlinBuiltIns.getInstance().getUnitType())) {
result = ErrorUtils.createErrorType(KotlinBuiltIns.getInstance().getUnit().getName().getName()); result = ErrorUtils.createErrorType(KotlinBuiltIns.getInstance().getUnit().getName().asString());
context.trace.report(INC_DEC_SHOULD_NOT_RETURN_UNIT.on(operationSign)); context.trace.report(INC_DEC_SHOULD_NOT_RETURN_UNIT.on(operationSign));
} }
else { else {
JetType receiverType = receiver.getType(); JetType receiverType = receiver.getType();
if (!JetTypeChecker.INSTANCE.isSubtypeOf(returnType, receiverType)) { if (!JetTypeChecker.INSTANCE.isSubtypeOf(returnType, receiverType)) {
context.trace.report(RESULT_TYPE_MISMATCH.on(operationSign, name.getName(), receiverType, returnType)); context.trace.report(RESULT_TYPE_MISMATCH.on(operationSign, name.asString(), receiverType, returnType));
} }
else { else {
context.trace.record(BindingContext.VARIABLE_REASSIGNMENT, expression); context.trace.record(BindingContext.VARIABLE_REASSIGNMENT, expression);
@@ -339,7 +339,7 @@ public class ControlStructureTypingVisitor extends ExpressionTypingVisitor {
VariableDescriptor olderVariable = context.scope.getLocalVariable(variableDescriptor.getName()); VariableDescriptor olderVariable = context.scope.getLocalVariable(variableDescriptor.getName());
if (olderVariable != null && DescriptorUtils.isLocal(context.scope.getContainingDeclaration(), olderVariable)) { if (olderVariable != null && DescriptorUtils.isLocal(context.scope.getContainingDeclaration(), olderVariable)) {
PsiElement declaration = BindingContextUtils.descriptorToDeclaration(context.trace.getBindingContext(), variableDescriptor); PsiElement declaration = BindingContextUtils.descriptorToDeclaration(context.trace.getBindingContext(), variableDescriptor);
context.trace.report(Errors.NAME_SHADOWING.on(declaration, variableDescriptor.getName().getName())); context.trace.report(Errors.NAME_SHADOWING.on(declaration, variableDescriptor.getName().asString()));
} }
} }
return variableDescriptor; return variableDescriptor;
@@ -136,7 +136,7 @@ public class DelegatedPropertyUtils {
List<JetExpression> arguments = Lists.newArrayList(); List<JetExpression> arguments = Lists.newArrayList();
arguments.add(createExpression(project, hasThis ? "this" : "null")); arguments.add(createExpression(project, hasThis ? "this" : "null"));
arguments.add(createExpression(project, KotlinBuiltIns.getInstance().getPropertyMetadataImpl().getName().getName() + "(\"" + propertyDescriptor.getName().getName() + "\")")); arguments.add(createExpression(project, KotlinBuiltIns.getInstance().getPropertyMetadataImpl().getName().asString() + "(\"" + propertyDescriptor.getName().asString() + "\")"));
if (!isGet) { if (!isGet) {
JetReferenceExpression fakeArgument = (JetReferenceExpression) createFakeExpressionOfType(context.expressionTypingServices.getProject(), trace, JetReferenceExpression fakeArgument = (JetReferenceExpression) createFakeExpressionOfType(context.expressionTypingServices.getProject(), trace,
@@ -148,7 +148,7 @@ public class DelegatedPropertyUtils {
} }
Name functionName = Name.identifier(isGet ? "get" : "set"); Name functionName = Name.identifier(isGet ? "get" : "set");
JetReferenceExpression fakeCalleeExpression = createSimpleName(project, functionName.getName()); JetReferenceExpression fakeCalleeExpression = createSimpleName(project, functionName.asString());
ExpressionReceiver receiver = new ExpressionReceiver(delegateExpression, delegateType); ExpressionReceiver receiver = new ExpressionReceiver(delegateExpression, delegateType);
call = CallMaker.makeCallWithExpressions(fakeCalleeExpression, receiver, null, fakeCalleeExpression, arguments, Call.CallType.DEFAULT); call = CallMaker.makeCallWithExpressions(fakeCalleeExpression, receiver, null, fakeCalleeExpression, arguments, Call.CallType.DEFAULT);
@@ -237,7 +237,7 @@ public class ExpressionTypingUtils {
@NotNull JetScope scope, @NotNull JetScope scope,
@NotNull ModuleDescriptor module @NotNull ModuleDescriptor module
) { ) {
JetImportDirective importDirective = JetPsiFactory.createImportDirective(project, callableFQN.getFqName()); JetImportDirective importDirective = JetPsiFactory.createImportDirective(project, callableFQN.asString());
Collection<? extends DeclarationDescriptor> declarationDescriptors = new QualifiedExpressionResolver() Collection<? extends DeclarationDescriptor> declarationDescriptors = new QualifiedExpressionResolver()
.analyseImportReference(importDirective, scope, new BindingTraceContext(), module); .analyseImportReference(importDirective, scope, new BindingTraceContext(), module);
@@ -436,7 +436,7 @@ public class ExpressionTypingUtils {
if (oldDescriptor != null && DescriptorUtils.isLocal(variableDescriptor.getContainingDeclaration(), oldDescriptor)) { if (oldDescriptor != null && DescriptorUtils.isLocal(variableDescriptor.getContainingDeclaration(), oldDescriptor)) {
PsiElement declaration = BindingContextUtils.descriptorToDeclaration(context.trace.getBindingContext(), variableDescriptor); PsiElement declaration = BindingContextUtils.descriptorToDeclaration(context.trace.getBindingContext(), variableDescriptor);
if (declaration != null) { if (declaration != null) {
context.trace.report(Errors.NAME_SHADOWING.on(declaration, variableDescriptor.getName().getName())); context.trace.report(Errors.NAME_SHADOWING.on(declaration, variableDescriptor.getName().asString()));
} }
} }
} }
@@ -263,9 +263,9 @@ public class KotlinBuiltIns {
} }
private void makePrimitive(PrimitiveType primitiveType) { private void makePrimitive(PrimitiveType primitiveType) {
ClassDescriptor theClass = getBuiltInClassByName(primitiveType.getTypeName().getName()); ClassDescriptor theClass = getBuiltInClassByName(primitiveType.getTypeName().asString());
JetType type = new JetTypeImpl(theClass); JetType type = new JetTypeImpl(theClass);
ClassDescriptor arrayClass = getBuiltInClassByName(primitiveType.getArrayTypeName().getName()); ClassDescriptor arrayClass = getBuiltInClassByName(primitiveType.getArrayTypeName().asString());
JetType arrayType = new JetTypeImpl(arrayClass); JetType arrayType = new JetTypeImpl(arrayClass);
primitiveTypeToClass.put(primitiveType, theClass); primitiveTypeToClass.put(primitiveType, theClass);
@@ -335,7 +335,7 @@ public class KotlinBuiltIns {
@NotNull @NotNull
public ClassDescriptor getPrimitiveClassDescriptor(@NotNull PrimitiveType type) { public ClassDescriptor getPrimitiveClassDescriptor(@NotNull PrimitiveType type) {
return getBuiltInClassByName(type.getTypeName().getName()); return getBuiltInClassByName(type.getTypeName().asString());
} }
@NotNull @NotNull
@@ -398,7 +398,7 @@ public class KotlinBuiltIns {
@NotNull @NotNull
public ClassDescriptor getPrimitiveArrayClassDescriptor(@NotNull PrimitiveType type) { public ClassDescriptor getPrimitiveArrayClassDescriptor(@NotNull PrimitiveType type) {
return getBuiltInClassByName(type.getArrayTypeName().getName()); return getBuiltInClassByName(type.getArrayTypeName().asString());
} }
@NotNull @NotNull
@@ -39,8 +39,8 @@ public final class QualifiedNamesUtil {
return true; return true;
} }
String subpackageNameStr = subpackageName.getFqName(); String subpackageNameStr = subpackageName.asString();
String packageNameStr = packageName.getFqName(); String packageNameStr = packageName.asString();
return (subpackageNameStr.startsWith(packageNameStr) && subpackageNameStr.charAt(packageNameStr.length()) == '.'); return (subpackageNameStr.startsWith(packageNameStr) && subpackageNameStr.charAt(packageNameStr.length()) == '.');
} }
@@ -54,7 +54,7 @@ public final class QualifiedNamesUtil {
} }
public static boolean isOneSegmentFQN(@NotNull FqName fqn) { public static boolean isOneSegmentFQN(@NotNull FqName fqn) {
return isOneSegmentFQN(fqn.getFqName()); return isOneSegmentFQN(fqn.asString());
} }
@NotNull @NotNull
@@ -74,7 +74,7 @@ public final class QualifiedNamesUtil {
return FqName.ROOT; return FqName.ROOT;
} }
String fqNameStr = fqName.getFqName(); String fqNameStr = fqName.asString();
return new FqName(fqNameStr.substring(fqNameStr.indexOf('.'), fqNameStr.length())); return new FqName(fqNameStr.substring(fqNameStr.indexOf('.'), fqNameStr.length()));
} }
@@ -93,12 +93,12 @@ public final class QualifiedNamesUtil {
@NotNull @NotNull
public static String tail(@NotNull FqName headFQN, @NotNull FqName fullFQN) { public static String tail(@NotNull FqName headFQN, @NotNull FqName fullFQN) {
if (!isSubpackageOf(fullFQN, headFQN) || headFQN.isRoot()) { if (!isSubpackageOf(fullFQN, headFQN) || headFQN.isRoot()) {
return fullFQN.getFqName(); return fullFQN.asString();
} }
return fullFQN.equals(headFQN) ? return fullFQN.equals(headFQN) ?
"" : "" :
fullFQN.getFqName().substring(headFQN.getFqName().length() + 1); // (headFQN + '.').length fullFQN.asString().substring(headFQN.asString().length() + 1); // (headFQN + '.').length
} }
/** /**
@@ -31,7 +31,7 @@ public class JetLightPackage extends PsiPackageImpl {
private final GlobalSearchScope scope; private final GlobalSearchScope scope;
public JetLightPackage(PsiManager manager, FqName qualifiedName, GlobalSearchScope scope) { public JetLightPackage(PsiManager manager, FqName qualifiedName, GlobalSearchScope scope) {
super(manager, qualifiedName.getFqName()); super(manager, qualifiedName.asString());
this.fqName = qualifiedName; this.fqName = qualifiedName;
this.scope = scope; this.scope = scope;
} }
@@ -189,7 +189,7 @@ public class KotlinJavaFileStubProvider implements CachedValueProvider<PsiJavaFi
private PsiJavaFileStub createJavaFileStub(@NotNull final FqName packageFqName, @NotNull VirtualFile virtualFile) { private PsiJavaFileStub createJavaFileStub(@NotNull final FqName packageFqName, @NotNull VirtualFile virtualFile) {
PsiManager manager = PsiManager.getInstance(project); PsiManager manager = PsiManager.getInstance(project);
final PsiJavaFileStubImpl javaFileStub = new PsiJavaFileStubImpl(packageFqName.getFqName(), true); final PsiJavaFileStubImpl javaFileStub = new PsiJavaFileStubImpl(packageFqName.asString(), true);
javaFileStub.setPsiFactory(new ClsWrapperStubPsiFactory()); javaFileStub.setPsiFactory(new ClsWrapperStubPsiFactory());
ClsFileImpl fakeFile = ClsFileImpl fakeFile =
@@ -203,7 +203,7 @@ public class KotlinJavaFileStubProvider implements CachedValueProvider<PsiJavaFi
@NotNull @NotNull
@Override @Override
public String getPackageName() { public String getPackageName() {
return packageFqName.getFqName(); return packageFqName.asString();
} }
}; };
@@ -175,7 +175,7 @@ public class KotlinLightClassForExplicitDeclaration extends AbstractLightClass i
@NotNull @NotNull
@Override @Override
public String getPackageName() { public String getPackageName() {
return JetPsiUtil.getFQName((JetFile) classOrObject.getContainingFile()).getFqName(); return JetPsiUtil.getFQName((JetFile) classOrObject.getContainingFile()).asString();
} }
@NotNull @NotNull
@@ -260,13 +260,13 @@ public class KotlinLightClassForExplicitDeclaration extends AbstractLightClass i
@Nullable @Nullable
@Override @Override
public String getName() { public String getName() {
return classFqName.shortName().getName(); return classFqName.shortName().asString();
} }
@Nullable @Nullable
@Override @Override
public String getQualifiedName() { public String getQualifiedName() {
return classFqName.getFqName(); return classFqName.asString();
} }
@NotNull @NotNull
@@ -339,7 +339,7 @@ public class KotlinLightClassForExplicitDeclaration extends AbstractLightClass i
} }
ClassDescriptor deprecatedAnnotation = KotlinBuiltIns.getInstance().getDeprecatedAnnotation(); ClassDescriptor deprecatedAnnotation = KotlinBuiltIns.getInstance().getDeprecatedAnnotation();
String deprecatedName = deprecatedAnnotation.getName().getName(); String deprecatedName = deprecatedAnnotation.getName().asString();
FqNameUnsafe deprecatedFqName = DescriptorUtils.getFQName(deprecatedAnnotation); FqNameUnsafe deprecatedFqName = DescriptorUtils.getFQName(deprecatedAnnotation);
for (JetAnnotationEntry annotationEntry : jetModifierList.getAnnotationEntries()) { for (JetAnnotationEntry annotationEntry : jetModifierList.getAnnotationEntries()) {
@@ -353,7 +353,7 @@ public class KotlinLightClassForExplicitDeclaration extends AbstractLightClass i
if (fqName == null) continue; if (fqName == null) continue;
if (deprecatedFqName.equals(fqName.toUnsafe())) return true; if (deprecatedFqName.equals(fqName.toUnsafe())) return true;
if (deprecatedName.equals(fqName.getFqName())) return true; if (deprecatedName.equals(fqName.asString())) return true;
} }
return false; return false;
} }
@@ -84,13 +84,13 @@ public class KotlinLightClassForPackage extends KotlinLightClassForPackageBase i
@Nullable @Nullable
@Override @Override
public String getName() { public String getName() {
return packageClassFqName.shortName().getName(); return packageClassFqName.shortName().asString();
} }
@Nullable @Nullable
@Override @Override
public String getQualifiedName() { public String getQualifiedName() {
return packageClassFqName.getFqName(); return packageClassFqName.asString();
} }
@Override @Override
@@ -99,7 +99,7 @@ public class LightClassUtil {
@Nullable @Nullable
/*package*/ static PsiClass findClass(@NotNull FqName fqn, @NotNull StubElement<?> stub) { /*package*/ static PsiClass findClass(@NotNull FqName fqn, @NotNull StubElement<?> stub) {
if (stub instanceof PsiClassStub && Comparing.equal(fqn.getFqName(), ((PsiClassStub) stub).getQualifiedName())) { if (stub instanceof PsiClassStub && Comparing.equal(fqn.asString(), ((PsiClassStub) stub).getQualifiedName())) {
return (PsiClass)stub.getPsi(); return (PsiClass)stub.getPsi();
} }
@@ -222,7 +222,7 @@ public class LightClassUtil {
if (jvmName != null) { if (jvmName != null) {
Project project = declaration.getProject(); Project project = declaration.getProject();
String fqName = jvmName.getFqName().getFqName(); String fqName = jvmName.getFqName().asString();
return JavaElementFinder.getInstance(project).findClass(fqName, GlobalSearchScope.allScope(project)); return JavaElementFinder.getInstance(project).findClass(fqName, GlobalSearchScope.allScope(project));
} }
} }
@@ -34,46 +34,46 @@ public class FqNameTest {
public void pathRoot() { public void pathRoot() {
List<FqName> path = new FqName("").path(); List<FqName> path = new FqName("").path();
Assert.assertEquals(1, path.size()); Assert.assertEquals(1, path.size());
Assert.assertEquals("", path.get(0).getFqName()); Assert.assertEquals("", path.get(0).asString());
} }
@Test @Test
public void pathLevel1() { public void pathLevel1() {
List<FqName> path = new FqName("com").path(); List<FqName> path = new FqName("com").path();
Assert.assertEquals(2, path.size()); Assert.assertEquals(2, path.size());
Assert.assertEquals("", path.get(0).getFqName()); Assert.assertEquals("", path.get(0).asString());
Assert.assertEquals("com", path.get(1).getFqName()); Assert.assertEquals("com", path.get(1).asString());
Assert.assertEquals("com", path.get(1).shortName().getName()); Assert.assertEquals("com", path.get(1).shortName().asString());
Assert.assertEquals("", path.get(1).parent().getFqName()); Assert.assertEquals("", path.get(1).parent().asString());
} }
@Test @Test
public void pathLevel2() { public void pathLevel2() {
List<FqName> path = new FqName("com.jetbrains").path(); List<FqName> path = new FqName("com.jetbrains").path();
Assert.assertEquals(3, path.size()); Assert.assertEquals(3, path.size());
Assert.assertEquals("", path.get(0).getFqName()); Assert.assertEquals("", path.get(0).asString());
Assert.assertEquals("com", path.get(1).getFqName()); Assert.assertEquals("com", path.get(1).asString());
Assert.assertEquals("com", path.get(1).shortName().getName()); Assert.assertEquals("com", path.get(1).shortName().asString());
Assert.assertEquals("", path.get(1).parent().getFqName()); Assert.assertEquals("", path.get(1).parent().asString());
Assert.assertEquals("com.jetbrains", path.get(2).getFqName()); Assert.assertEquals("com.jetbrains", path.get(2).asString());
Assert.assertEquals("jetbrains", path.get(2).shortName().getName()); Assert.assertEquals("jetbrains", path.get(2).shortName().asString());
Assert.assertEquals("com", path.get(2).parent().getFqName()); Assert.assertEquals("com", path.get(2).parent().asString());
} }
@Test @Test
public void pathLevel3() { public void pathLevel3() {
List<FqName> path = new FqName("com.jetbrains.jet").path(); List<FqName> path = new FqName("com.jetbrains.jet").path();
Assert.assertEquals(4, path.size()); Assert.assertEquals(4, path.size());
Assert.assertEquals("", path.get(0).getFqName()); Assert.assertEquals("", path.get(0).asString());
Assert.assertEquals("com", path.get(1).getFqName()); Assert.assertEquals("com", path.get(1).asString());
Assert.assertEquals("com", path.get(1).shortName().getName()); Assert.assertEquals("com", path.get(1).shortName().asString());
Assert.assertEquals("", path.get(1).parent().getFqName()); Assert.assertEquals("", path.get(1).parent().asString());
Assert.assertEquals("com.jetbrains", path.get(2).getFqName()); Assert.assertEquals("com.jetbrains", path.get(2).asString());
Assert.assertEquals("jetbrains", path.get(2).shortName().getName()); Assert.assertEquals("jetbrains", path.get(2).shortName().asString());
Assert.assertEquals("com", path.get(2).parent().getFqName()); Assert.assertEquals("com", path.get(2).parent().asString());
Assert.assertEquals("com.jetbrains.jet", path.get(3).getFqName()); Assert.assertEquals("com.jetbrains.jet", path.get(3).asString());
Assert.assertEquals("jet", path.get(3).shortName().getName()); Assert.assertEquals("jet", path.get(3).shortName().asString());
Assert.assertEquals("com.jetbrains", path.get(3).parent().getFqName()); Assert.assertEquals("com.jetbrains", path.get(3).parent().asString());
} }
@Test @Test
@@ -84,7 +84,7 @@ public class FqNameTest {
List<Name> segments = new FqName(name).pathSegments(); List<Name> segments = new FqName(name).pathSegments();
List<String> segmentsStrings = new ArrayList<String>(); List<String> segmentsStrings = new ArrayList<String>();
for (Name segment : segments) { for (Name segment : segments) {
segmentsStrings.add(segment.getName()); segmentsStrings.add(segment.asString());
} }
Assert.assertEquals(Arrays.asList(name.split("\\.")), segmentsStrings); Assert.assertEquals(Arrays.asList(name.split("\\.")), segmentsStrings);
} }
@@ -137,7 +137,7 @@ public abstract class CodegenTestCase extends UsefulTestCase {
@NotNull @NotNull
protected Class<?> generateNamespaceClass() { protected Class<?> generateNamespaceClass() {
JvmClassName name = NamespaceCodegen.getJVMClassNameForKotlinNs(JetPsiUtil.getFQName(myFiles.getPsiFile())); JvmClassName name = NamespaceCodegen.getJVMClassNameForKotlinNs(JetPsiUtil.getFQName(myFiles.getPsiFile()));
return generateClass(name.getFqName().getFqName()); return generateClass(name.getFqName().asString());
} }
@NotNull @NotNull
@@ -97,7 +97,7 @@ public abstract class AbstractBlackBoxCodegenTest extends CodegenTestCase {
// If there are many files, the first of them should contain the 'box(): String' function // If there are many files, the first of them should contain the 'box(): String' function
JetFile firstFile = myFiles.getPsiFiles().get(0); JetFile firstFile = myFiles.getPsiFiles().get(0);
String fqName = NamespaceCodegen.getJVMClassNameForKotlinNs(JetPsiUtil.getFQName(firstFile)).getFqName().getFqName(); String fqName = NamespaceCodegen.getJVMClassNameForKotlinNs(JetPsiUtil.getFQName(firstFile)).getFqName().asString();
try { try {
Class<?> namespaceClass = loader.loadClass(fqName); Class<?> namespaceClass = loader.loadClass(fqName);
@@ -54,7 +54,7 @@ public abstract class AbstractLoadCompiledKotlinTest extends TestCaseWithTmpdir
NamespaceDescriptor namespaceFromSource = exhaust.getBindingContext().get(BindingContext.FQNAME_TO_NAMESPACE_DESCRIPTOR, NamespaceDescriptor namespaceFromSource = exhaust.getBindingContext().get(BindingContext.FQNAME_TO_NAMESPACE_DESCRIPTOR,
TEST_PACKAGE_FQNAME); TEST_PACKAGE_FQNAME);
assert namespaceFromSource != null; assert namespaceFromSource != null;
Assert.assertEquals("test", namespaceFromSource.getName().getName()); Assert.assertEquals("test", namespaceFromSource.getName().asString());
NamespaceDescriptor namespaceFromClass = LoadDescriptorUtil.loadTestNamespaceAndBindingContextFromJavaRoot( NamespaceDescriptor namespaceFromClass = LoadDescriptorUtil.loadTestNamespaceAndBindingContextFromJavaRoot(
tmpdir, getTestRootDisposable(), ConfigurationKind.JDK_ONLY).first; tmpdir, getTestRootDisposable(), ConfigurationKind.JDK_ONLY).first;
compareNamespaces(namespaceFromSource, namespaceFromClass, compareNamespaces(namespaceFromSource, namespaceFromClass,
@@ -28,7 +28,6 @@ import org.jetbrains.jet.lang.resolve.constants.CompileTimeConstant;
import org.jetbrains.jet.lang.resolve.scopes.JetScope; import org.jetbrains.jet.lang.resolve.scopes.JetScope;
import org.jetbrains.jet.renderer.DescriptorRenderer; import org.jetbrains.jet.renderer.DescriptorRenderer;
import java.io.File;
import java.util.*; import java.util.*;
import static com.intellij.testFramework.UsefulTestCase.assertNotNull; import static com.intellij.testFramework.UsefulTestCase.assertNotNull;
@@ -85,7 +84,7 @@ public class ExpectedLoadErrorsUtil {
ClassDescriptor annotationClass = (ClassDescriptor) annotation.getType().getConstructor().getDeclarationDescriptor(); ClassDescriptor annotationClass = (ClassDescriptor) annotation.getType().getConstructor().getDeclarationDescriptor();
assert annotationClass != null; assert annotationClass != null;
if (DescriptorUtils.getFQName(annotationClass).getFqName().equals(ANNOTATION_CLASS_NAME)) { if (DescriptorUtils.getFQName(annotationClass).asString().equals(ANNOTATION_CLASS_NAME)) {
// we expect exactly one annotation argument // we expect exactly one annotation argument
CompileTimeConstant<?> argument = annotation.getAllValueArguments().values().iterator().next(); CompileTimeConstant<?> argument = annotation.getAllValueArguments().values().iterator().next();
@@ -79,7 +79,7 @@ public class IdeaJdkAnnotationsReflectedTest extends KotlinTestWithEnvironment {
if (new FqName("org.jdom").equals(classFqName.parent())) continue; // filter unrelated jdom annotations if (new FqName("org.jdom").equals(classFqName.parent())) continue; // filter unrelated jdom annotations
if (new FqName("java.util.concurrent.TransferQueue").equals(classFqName)) continue; // filter JDK7-specific class if (new FqName("java.util.concurrent.TransferQueue").equals(classFqName)) continue; // filter JDK7-specific class
PsiClass psiClass = javaPsiFacade.findClass(classFqName.getFqName(), allScope); PsiClass psiClass = javaPsiFacade.findClass(classFqName.asString(), allScope);
assertNotNull("Class has annotation, but it is not found: " + classFqName, psiClass); assertNotNull("Class has annotation, but it is not found: " + classFqName, psiClass);
psiClass.accept(new JavaRecursiveElementVisitor() { psiClass.accept(new JavaRecursiveElementVisitor() {
@@ -111,7 +111,7 @@ public class IdeaJdkAnnotationsReflectedTest extends KotlinTestWithEnvironment {
if (hasAnnotation(ideaFakeAnnotationsManager, ideaOwner, AnnotationUtil.NOT_NULL)) { if (hasAnnotation(ideaFakeAnnotationsManager, ideaOwner, AnnotationUtil.NOT_NULL)) {
boolean kotlinHasNotNull = hasAnnotation(kotlinFakeAnnotationsManager, kotlinOwner, AnnotationUtil.NOT_NULL); boolean kotlinHasNotNull = hasAnnotation(kotlinFakeAnnotationsManager, kotlinOwner, AnnotationUtil.NOT_NULL);
boolean kotlinHasKotlinSignature = hasAnnotation(kotlinFakeAnnotationsManager, kotlinOwner, boolean kotlinHasKotlinSignature = hasAnnotation(kotlinFakeAnnotationsManager, kotlinOwner,
JvmStdlibNames.KOTLIN_SIGNATURE.getFqName().getFqName()); JvmStdlibNames.KOTLIN_SIGNATURE.getFqName().asString());
if (kotlinOwner == ideaOwner && kotlinHasNotNull || kotlinHasKotlinSignature) { if (kotlinOwner == ideaOwner && kotlinHasNotNull || kotlinHasKotlinSignature) {
// good // good
} }
@@ -61,8 +61,8 @@ public class JvmClassNameTest {
) { ) {
JvmClassName mapEntryName = JvmClassName.bySignatureName(className); JvmClassName mapEntryName = JvmClassName.bySignatureName(className);
assertEquals(innerClassName, mapEntryName.getInternalName()); assertEquals(innerClassName, mapEntryName.getInternalName());
assertEquals(fqName, mapEntryName.getFqName().getFqName()); assertEquals(fqName, mapEntryName.getFqName().asString());
assertEquals(outerClassName, mapEntryName.getOuterClassFqName().getFqName()); assertEquals(outerClassName, mapEntryName.getOuterClassFqName().asString());
assertEquals(innerClassNameList, mapEntryName.getInnerClassNameList()); assertEquals(innerClassNameList, mapEntryName.getInnerClassNameList());
} }
} }
@@ -131,7 +131,7 @@ public class NamespaceComparator {
private boolean shouldSkip(@NotNull DeclarationDescriptor subDescriptor) { private boolean shouldSkip(@NotNull DeclarationDescriptor subDescriptor) {
return subDescriptor.getContainingDeclaration() instanceof ClassDescriptor return subDescriptor.getContainingDeclaration() instanceof ClassDescriptor
&& subDescriptor instanceof FunctionDescriptor && subDescriptor instanceof FunctionDescriptor
&& JAVA_OBJECT_METHOD_NAMES.contains(subDescriptor.getName().getName()) && JAVA_OBJECT_METHOD_NAMES.contains(subDescriptor.getName().asString())
&& !conf.includeMethodsOfJavaObject && !conf.includeMethodsOfJavaObject
|| ||
subDescriptor instanceof NamespaceDescriptor && !conf.recurseIntoPackage.apply(DescriptorUtils.getFQName(subDescriptor)); subDescriptor instanceof NamespaceDescriptor && !conf.recurseIntoPackage.apply(DescriptorUtils.getFQName(subDescriptor));
@@ -53,7 +53,7 @@ import static org.jetbrains.jet.lang.resolve.java.JavaToKotlinMethodMap.serializ
public class GenerateJavaToKotlinMethodMap { public class GenerateJavaToKotlinMethodMap {
public static final String BUILTINS_FQNAME_PREFIX = KotlinBuiltIns.BUILT_INS_PACKAGE_FQ_NAME.getFqName() + "."; public static final String BUILTINS_FQNAME_PREFIX = KotlinBuiltIns.BUILT_INS_PACKAGE_FQ_NAME.asString() + ".";
public static void main(String[] args) throws IOException { public static void main(String[] args) throws IOException {
CompilerConfiguration configuration = new CompilerConfiguration(); CompilerConfiguration configuration = new CompilerConfiguration();
@@ -207,7 +207,7 @@ public class GenerateJavaToKotlinMethodMap {
private void appendBeforeClass(@NotNull ClassDescriptor kotlinClass, @NotNull PsiClass psiClass) { private void appendBeforeClass(@NotNull ClassDescriptor kotlinClass, @NotNull PsiClass psiClass) {
String psiFqName = psiClass.getQualifiedName(); String psiFqName = psiClass.getQualifiedName();
String kotlinFqName = DescriptorUtils.getFQName(kotlinClass).toSafe().getFqName(); String kotlinFqName = DescriptorUtils.getFQName(kotlinClass).toSafe().asString();
assert kotlinFqName.startsWith(BUILTINS_FQNAME_PREFIX); assert kotlinFqName.startsWith(BUILTINS_FQNAME_PREFIX);
String kotlinSubQualifiedName = kotlinFqName.substring(BUILTINS_FQNAME_PREFIX.length()); String kotlinSubQualifiedName = kotlinFqName.substring(BUILTINS_FQNAME_PREFIX.length());
@@ -44,11 +44,11 @@ public class JetPluginUtil {
LinkedList<String> fullName = Lists.newLinkedList(); LinkedList<String> fullName = Lists.newLinkedList();
while (declarationDescriptor != null && !(declarationDescriptor instanceof ModuleDescriptor)) { while (declarationDescriptor != null && !(declarationDescriptor instanceof ModuleDescriptor)) {
fullName.addFirst(declarationDescriptor.getName().getName()); fullName.addFirst(declarationDescriptor.getName().asString());
declarationDescriptor = declarationDescriptor.getContainingDeclaration(); declarationDescriptor = declarationDescriptor.getContainingDeclaration();
} }
assert fullName.size() > 0; assert fullName.size() > 0;
if (JavaDescriptorResolver.JAVA_ROOT.getName().equals(fullName.getFirst())) { if (JavaDescriptorResolver.JAVA_ROOT.asString().equals(fullName.getFirst())) {
fullName.removeFirst(); fullName.removeFirst();
} }
return fullName; return fullName;
@@ -107,7 +107,7 @@ public class JetAddImportAction implements QuestionAction {
return FINAL_CHOICE; return FINAL_CHOICE;
} }
List<String> toExclude = AddImportAction.getAllExcludableStrings(selectedValue.getFqName()); List<String> toExclude = AddImportAction.getAllExcludableStrings(selectedValue.asString());
return new BaseListPopupStep<String>(null, toExclude) { return new BaseListPopupStep<String>(null, toExclude) {
@NotNull @NotNull
@@ -135,7 +135,7 @@ public class JetAddImportAction implements QuestionAction {
@NotNull @NotNull
@Override @Override
public String getTextFor(FqName value) { public String getTextFor(FqName value) {
return value.getFqName(); return value.asString();
} }
@Override @Override
@@ -39,7 +39,7 @@ public class JetGotoClassContributor implements GotoClassContributor {
JetNamedDeclaration jetClass = (JetNamedDeclaration) item; JetNamedDeclaration jetClass = (JetNamedDeclaration) item;
FqName name = JetPsiUtil.getFQName(jetClass); FqName name = JetPsiUtil.getFQName(jetClass);
if (name != null) { if (name != null) {
return name.getFqName(); return name.asString();
} }
} }
@@ -107,7 +107,7 @@ public class JetShortNamesCache extends PsiShortNamesCache {
Collection<FqName> fqNames = packageClasses.get(name); Collection<FqName> fqNames = packageClasses.get(name);
if (!fqNames.isEmpty()) { if (!fqNames.isEmpty()) {
for (FqName fqName : fqNames) { for (FqName fqName : fqNames) {
PsiClass psiClass = JavaElementFinder.getInstance(project).findClass(fqName.getFqName(), scope); PsiClass psiClass = JavaElementFinder.getInstance(project).findClass(fqName.asString(), scope);
if (psiClass != null) { if (psiClass != null) {
result.add(psiClass); result.add(psiClass);
} }
@@ -123,10 +123,10 @@ public class JetShortNamesCache extends PsiShortNamesCache {
for (JetClassOrObject classOrObject : classOrObjects) { for (JetClassOrObject classOrObject : classOrObjects) {
FqName fqName = JetPsiUtil.getFQName(classOrObject); FqName fqName = JetPsiUtil.getFQName(classOrObject);
if (fqName != null) { if (fqName != null) {
assert fqName.shortName().getName().equals(name) : "A declaration obtained from index has non-matching name:\n" + assert fqName.shortName().asString().equals(name) : "A declaration obtained from index has non-matching name:\n" +
"in index: " + name + "\n" + "in index: " + name + "\n" +
"declared: " + fqName.shortName() + "(" + fqName + ")"; "declared: " + fqName.shortName() + "(" + fqName + ")";
PsiClass psiClass = JavaElementFinder.getInstance(project).findClass(fqName.getFqName(), scope); PsiClass psiClass = JavaElementFinder.getInstance(project).findClass(fqName.asString(), scope);
if (psiClass != null) { if (psiClass != null) {
result.add(psiClass); result.add(psiClass);
} }
@@ -230,7 +230,7 @@ public class JetShortNamesCache extends PsiShortNamesCache {
Set<FunctionDescriptor> result = Sets.newHashSet(); Set<FunctionDescriptor> result = Sets.newHashSet();
Collection<PsiMethod> topLevelFunctionPrototypes = JetFromJavaDescriptorHelper.getTopLevelFunctionPrototypesByName( Collection<PsiMethod> topLevelFunctionPrototypes = JetFromJavaDescriptorHelper.getTopLevelFunctionPrototypesByName(
referenceName.getName(), project, scope); referenceName.asString(), project, scope);
for (PsiMethod method : topLevelFunctionPrototypes) { for (PsiMethod method : topLevelFunctionPrototypes) {
FqName functionFQN = JetFromJavaDescriptorHelper.getJetTopLevelDeclarationFQN(method); FqName functionFQN = JetFromJavaDescriptorHelper.getJetTopLevelDeclarationFQN(method);
if (functionFQN != null) { if (functionFQN != null) {
@@ -246,7 +246,7 @@ public class JetShortNamesCache extends PsiShortNamesCache {
} }
Set<FqName> affectedPackages = Sets.newHashSet(); Set<FqName> affectedPackages = Sets.newHashSet();
Collection<JetNamedFunction> jetNamedFunctions = JetShortFunctionNameIndex.getInstance().get(referenceName.getName(), project, scope); Collection<JetNamedFunction> jetNamedFunctions = JetShortFunctionNameIndex.getInstance().get(referenceName.asString(), project, scope);
for (JetNamedFunction jetNamedFunction : jetNamedFunctions) { for (JetNamedFunction jetNamedFunction : jetNamedFunctions) {
PsiFile containingFile = jetNamedFunction.getContainingFile(); PsiFile containingFile = jetNamedFunction.getContainingFile();
if (containingFile instanceof JetFile) { if (containingFile instanceof JetFile) {
@@ -354,7 +354,7 @@ public class JetShortNamesCache extends PsiShortNamesCache {
for (String fqName : JetFullClassNameIndex.getInstance().getAllKeys(project)) { for (String fqName : JetFullClassNameIndex.getInstance().getAllKeys(project)) {
FqName classFQName = new FqName(fqName); FqName classFQName = new FqName(fqName);
if (acceptedShortNameCondition.value(classFQName.shortName().getName())) { if (acceptedShortNameCondition.value(classFQName.shortName().asString())) {
classDescriptors.addAll(getJetClassesDescriptorsByFQName(analyzer, classFQName)); classDescriptors.addAll(getJetClassesDescriptorsByFQName(analyzer, classFQName));
} }
} }
@@ -364,7 +364,7 @@ public class JetShortNamesCache extends PsiShortNamesCache {
private Collection<ClassDescriptor> getJetClassesDescriptorsByFQName(@NotNull KotlinCodeAnalyzer analyzer, @NotNull FqName classFQName) { private Collection<ClassDescriptor> getJetClassesDescriptorsByFQName(@NotNull KotlinCodeAnalyzer analyzer, @NotNull FqName classFQName) {
Collection<JetClassOrObject> jetClassOrObjects = JetFullClassNameIndex.getInstance().get( Collection<JetClassOrObject> jetClassOrObjects = JetFullClassNameIndex.getInstance().get(
classFQName.getFqName(), project, GlobalSearchScope.allScope(project)); classFQName.asString(), project, GlobalSearchScope.allScope(project));
if (jetClassOrObjects.isEmpty()) { if (jetClassOrObjects.isEmpty()) {
// This fqn is absent in caches, dead or not in scope // This fqn is absent in caches, dead or not in scope
@@ -31,11 +31,9 @@ import org.jetbrains.annotations.Nullable;
import org.jetbrains.jet.asJava.KotlinLightClassForExplicitDeclaration; import org.jetbrains.jet.asJava.KotlinLightClassForExplicitDeclaration;
import org.jetbrains.jet.asJava.LightClassConstructionContext; import org.jetbrains.jet.asJava.LightClassConstructionContext;
import org.jetbrains.jet.asJava.LightClassGenerationSupport; import org.jetbrains.jet.asJava.LightClassGenerationSupport;
import org.jetbrains.jet.codegen.binding.PsiCodegenPredictor;
import org.jetbrains.jet.lang.psi.JetClassOrObject; import org.jetbrains.jet.lang.psi.JetClassOrObject;
import org.jetbrains.jet.lang.psi.JetFile; import org.jetbrains.jet.lang.psi.JetFile;
import org.jetbrains.jet.lang.psi.JetPsiUtil; import org.jetbrains.jet.lang.psi.JetPsiUtil;
import org.jetbrains.jet.lang.resolve.java.JvmClassName;
import org.jetbrains.jet.lang.resolve.java.PackageClassUtils; import org.jetbrains.jet.lang.resolve.java.PackageClassUtils;
import org.jetbrains.jet.lang.resolve.name.FqName; import org.jetbrains.jet.lang.resolve.name.FqName;
import org.jetbrains.jet.plugin.libraries.JetSourceNavigationHelper; import org.jetbrains.jet.plugin.libraries.JetSourceNavigationHelper;
@@ -70,13 +68,13 @@ public class IDELightClassGenerationSupport extends LightClassGenerationSupport
@NotNull @NotNull
@Override @Override
public Collection<JetClassOrObject> findClassOrObjectDeclarations(@NotNull FqName fqName, @NotNull GlobalSearchScope searchScope) { public Collection<JetClassOrObject> findClassOrObjectDeclarations(@NotNull FqName fqName, @NotNull GlobalSearchScope searchScope) {
return JetFullClassNameIndex.getInstance().get(fqName.getFqName(), project, kotlinSources(searchScope)); return JetFullClassNameIndex.getInstance().get(fqName.asString(), project, kotlinSources(searchScope));
} }
@NotNull @NotNull
@Override @Override
public Collection<JetFile> findFilesForPackage(@NotNull final FqName fqName, @NotNull GlobalSearchScope searchScope) { public Collection<JetFile> findFilesForPackage(@NotNull final FqName fqName, @NotNull GlobalSearchScope searchScope) {
Collection<JetFile> files = JetAllPackagesIndex.getInstance().get(fqName.getFqName(), project, kotlinSources(searchScope)); Collection<JetFile> files = JetAllPackagesIndex.getInstance().get(fqName.asString(), project, kotlinSources(searchScope));
return ContainerUtil.filter(files, new Condition<JetFile>() { return ContainerUtil.filter(files, new Condition<JetFile>() {
@Override @Override
public boolean value(JetFile file) { public boolean value(JetFile file) {
@@ -90,20 +88,20 @@ public class IDELightClassGenerationSupport extends LightClassGenerationSupport
public Collection<JetClassOrObject> findClassOrObjectDeclarationsInPackage( public Collection<JetClassOrObject> findClassOrObjectDeclarationsInPackage(
@NotNull FqName packageFqName, @NotNull GlobalSearchScope searchScope @NotNull FqName packageFqName, @NotNull GlobalSearchScope searchScope
) { ) {
return JetClassByPackageIndex.getInstance().get(packageFqName.getFqName(), project, kotlinSources(searchScope)); return JetClassByPackageIndex.getInstance().get(packageFqName.asString(), project, kotlinSources(searchScope));
} }
@Override @Override
public boolean packageExists( public boolean packageExists(
@NotNull FqName fqName, @NotNull GlobalSearchScope scope @NotNull FqName fqName, @NotNull GlobalSearchScope scope
) { ) {
return !JetAllPackagesIndex.getInstance().get(fqName.getFqName(), project, kotlinSources(scope)).isEmpty(); return !JetAllPackagesIndex.getInstance().get(fqName.asString(), project, kotlinSources(scope)).isEmpty();
} }
@NotNull @NotNull
@Override @Override
public Collection<FqName> getSubPackages(@NotNull FqName fqn, @NotNull GlobalSearchScope scope) { public Collection<FqName> getSubPackages(@NotNull FqName fqn, @NotNull GlobalSearchScope scope) {
Collection<JetFile> files = JetAllPackagesIndex.getInstance().get(fqn.getFqName(), project, kotlinSources(scope)); Collection<JetFile> files = JetAllPackagesIndex.getInstance().get(fqn.asString(), project, kotlinSources(scope));
Set<FqName> result = Sets.newHashSet(); Set<FqName> result = Sets.newHashSet();
for (JetFile file : files) { for (JetFile file : files) {
@@ -141,7 +139,7 @@ public class IDELightClassGenerationSupport extends LightClassGenerationSupport
Collection<JetFile> files = findFilesForPackage(new FqName(packageFqName), scope); Collection<JetFile> files = findFilesForPackage(new FqName(packageFqName), scope);
if (!files.isEmpty()) { if (!files.isEmpty()) {
FqName packageClassFqName = PackageClassUtils.getPackageClassFqName(new FqName(packageFqName)); FqName packageClassFqName = PackageClassUtils.getPackageClassFqName(new FqName(packageFqName));
result.putValue(packageClassFqName.shortName().getName(), packageClassFqName); result.putValue(packageClassFqName.shortName().asString(), packageClassFqName);
} }
} }
@@ -81,7 +81,7 @@ public class ReferenceToClassesShortening {
} }
private void compactReferenceToClass(JetUserType userType, ClassDescriptor targetClass) { private void compactReferenceToClass(JetUserType userType, ClassDescriptor targetClass) {
String name = targetClass.getName().getName(); String name = targetClass.getName().asString();
DeclarationDescriptor parent = targetClass.getContainingDeclaration(); DeclarationDescriptor parent = targetClass.getContainingDeclaration();
while (parent instanceof ClassDescriptor) { while (parent instanceof ClassDescriptor) {
name = parent.getName() + "." + name; name = parent.getName() + "." + name;
@@ -30,7 +30,7 @@ import org.jetbrains.jet.lang.resolve.java.JvmStdlibNames;
import org.jetbrains.jet.lang.resolve.java.resolver.JavaAnnotationResolver; import org.jetbrains.jet.lang.resolve.java.resolver.JavaAnnotationResolver;
class KotlinSignatureUtil { class KotlinSignatureUtil {
static final String KOTLIN_SIGNATURE_ANNOTATION = JvmStdlibNames.KOTLIN_SIGNATURE.getFqName().getFqName(); static final String KOTLIN_SIGNATURE_ANNOTATION = JvmStdlibNames.KOTLIN_SIGNATURE.getFqName().asString();
private KotlinSignatureUtil() { private KotlinSignatureUtil() {
} }
@@ -68,9 +68,9 @@ public final class DescriptorLookupConverter {
} }
LookupElementBuilder element = LookupElementBuilder.create( LookupElementBuilder element = LookupElementBuilder.create(
new JetLookupObject(descriptor, analyzer, declaration), descriptor.getName().getName()); new JetLookupObject(descriptor, analyzer, declaration), descriptor.getName().asString());
String presentableText = descriptor.getName().getName(); String presentableText = descriptor.getName().asString();
String typeText = ""; String typeText = "";
String tailText = ""; String tailText = "";
boolean tailTextGrayed = true; boolean tailTextGrayed = true;

Some files were not shown because too many files have changed in this diff Show More