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();
genAnnotationValueArgument(annotationVisitor, valueArgument, keyName.getName());
genAnnotationValueArgument(annotationVisitor, valueArgument, keyName.asString());
}
}
@@ -152,7 +152,7 @@ public abstract class AnnotationCodegen {
if (call != null) {
if (call.getResultingDescriptor() instanceof PropertyDescriptor) {
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;
}
}
@@ -168,7 +168,7 @@ public abstract class AnnotationCodegen {
if (annotations != null) {
for (AnnotationDescriptor annotation : annotations) {
//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();
break;
}
@@ -505,7 +505,7 @@ public class AsmUtil {
Type asmType = state.getTypeMapper().mapReturnType(type);
if (asmType.getSort() == Type.OBJECT || asmType.getSort() == Type.ARRAY) {
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");
}
}
@@ -546,8 +546,8 @@ public class AsmUtil {
Type asmType = state.getTypeMapper().mapReturnType(type);
if (asmType.getSort() == Type.OBJECT || asmType.getSort() == Type.ARRAY) {
v.dup();
v.visitLdcInsn(descriptor.getContainingDeclaration().getName().getName());
v.visitLdcInsn(descriptor.getName().getName());
v.visitLdcInsn(descriptor.getContainingDeclaration().getName().asString());
v.visitLdcInsn(descriptor.getName().asString());
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;
}
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);
if (state.getClassBuilderMode() == ClassBuilderMode.STUBS) {
genStubCode(mv);
@@ -203,7 +203,7 @@ public class ClosureCodegen extends GenerationStateAware {
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);
iv.areturn(bridge.getReturnType());
@@ -268,11 +268,11 @@ public class ClosureCodegen extends GenerationStateAware {
Type type = sharedVarType != null
? sharedVarType
: 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)) {
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) {
assert captureReceiver != null;
@@ -560,7 +560,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
@Override
public void run() {
myFrameMap.leave(parameterDescriptor);
v.visitLocalVariable(parameterDescriptor.getName().getName(),
v.visitLocalVariable(parameterDescriptor.getName().asString(),
asmTypeForParameter.getDescriptor(), null,
bodyStart, bodyEnd,
loopParameterVar);
@@ -601,7 +601,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
@Override
public void run() {
myFrameMap.leave(componentDescriptor);
v.visitLocalVariable(componentDescriptor.getName().getName(),
v.visitLocalVariable(componentDescriptor.getName().asString(),
componentAsmType.getDescriptor(), null,
bodyStart, bodyEnd,
componentVarIndex);
@@ -1414,7 +1414,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
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);
return null;
}
@@ -1628,7 +1628,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
ClassDescriptor containing = (ClassDescriptor) variableDescriptor.getContainingDeclaration().getContainingDeclaration();
assert containing != null;
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 {
return StackValue.singleton(objectClassDescriptor, typeMapper);
@@ -2924,7 +2924,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
else {
DeclarationDescriptor cls = op.getContainingDeclaration();
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);
}
else {
@@ -2981,14 +2981,14 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
if (op instanceof FunctionDescriptor) {
Type asmType = expressionType(expression);
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)) {
receiver.put(receiver.type, v);
JetExpression operand = expression.getBaseExpression();
if (operand instanceof JetReferenceExpression) {
int index = indexOfLocal((JetReferenceExpression) operand);
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);
}
}
@@ -3053,7 +3053,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
}
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) {
int index = indexOfLocal((JetReferenceExpression) operand);
if (index >= 0 && isIntPrimitive(asmType)) {
@@ -41,7 +41,7 @@ public class FieldInfo {
Type ownerType = typeMapper.mapType(ownerDescriptor.getDefaultType());
String fieldName = kind == ClassKind.ENUM_ENTRY
? fieldClassDescriptor.getName().getName()
? fieldClassDescriptor.getName().asString()
: fieldClassDescriptor.getKind() == ClassKind.CLASS_OBJECT ? JvmAbi.CLASS_OBJECT_FIELD : JvmAbi.INSTANCE_FIELD;
return new FieldInfo(ownerType, fieldType, fieldName, true);
}
@@ -200,7 +200,7 @@ public class FunctionCodegen extends GenerationStateAware {
List<ValueParameterDescriptor> parameters = functionDescriptor.getValueParameters();
List<String> result = new ArrayList<String>(parameters.size());
for (ValueParameterDescriptor parameter : parameters) {
result.add(parameter.getName().getName());
result.add(parameter.getName().asString());
}
return result;
}
@@ -244,7 +244,7 @@ public class FunctionCodegen extends GenerationStateAware {
if (kind == JvmMethodParameterKind.VALUE) {
ValueParameterDescriptor parameter = valueParameters.next();
Label divideLabel = labelsForSharedVars.get(parameter.getName());
parameterName = parameter.getName().getName();
parameterName = parameter.getName().asString();
if (divideLabel != null) {
mv.visitLocalVariable(parameterName, type.getDescriptor(), null, methodBegin, divideLabel, shift);
@@ -377,7 +377,7 @@ public class FunctionCodegen extends GenerationStateAware {
ValueParameterDescriptor parameterDescriptor = null;
if (kind == JvmMethodParameterKind.VALUE) {
parameterDescriptor = valueParameters.next();
parameterName = parameterDescriptor.getName().getName();
parameterName = parameterDescriptor.getName().asString();
} 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
continue;
@@ -297,7 +297,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
innerClassInternalName = outerClassInternalName + JvmAbi.CLASS_OBJECT_SUFFIX;
}
else {
innerName = innerClass.getName().isSpecial() ? null : innerClass.getName().getName();
innerName = innerClass.getName().isSpecial() ? null : innerClass.getName().asString();
innerClassInternalName = getInternalNameForImpl(innerClass);
}
@@ -620,11 +620,11 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
boolean first = true;
for (PropertyDescriptor propertyDescriptor : properties) {
if (first) {
iv.aconst(descriptor.getName() + "(" + propertyDescriptor.getName().getName()+"=");
iv.aconst(descriptor.getName() + "(" + propertyDescriptor.getName().asString()+"=");
first = false;
}
else {
iv.aconst(", " + propertyDescriptor.getName().getName()+"=");
iv.aconst(", " + propertyDescriptor.getName().asString()+"=");
}
genInvokeAppendMethod(iv, JAVA_STRING_TYPE);
@@ -821,7 +821,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
Type[] argTypes = method.getArgumentTypes();
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);
if (state.getClassBuilderMode() == ClassBuilderMode.STUBS) {
genStubCode(mv);
@@ -1015,7 +1015,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
Type type = typeMapper.mapType(descriptor);
iv.load(0, classAsmType);
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++;
}
@@ -1097,7 +1097,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
Boolean.TRUE.equals(bindingContext.get(BindingContext.BACKING_FIELD_REQUIRED, propertyDescriptor))) {
// final property with backing field
field = StackValue.field(typeMapper.mapType(propertyDescriptor.getType()), classname,
propertyDescriptor.getName().getName(), false);
propertyDescriptor.getName().asString(), false);
}
else {
iv.load(0, classType);
@@ -148,7 +148,7 @@ public class PropertyCodegen extends GenerationStateAware {
modifiers |= ACC_VOLATILE;
}
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) {
@@ -248,7 +248,7 @@ public class PropertyCodegen extends GenerationStateAware {
iv.visitFieldInsn(
kind == OwnerKind.NAMESPACE ? GETSTATIC : GETFIELD,
typeMapper.getOwner(propertyDescriptor, kind, isCallInsideSameModuleAsDeclared(propertyDescriptor, context)).getInternalName(),
propertyDescriptor.getName().getName(),
propertyDescriptor.getName().asString(),
type.getDescriptor());
iv.areturn(type);
}
@@ -265,7 +265,7 @@ public class PropertyCodegen extends GenerationStateAware {
iv.load(paramCode, type);
iv.visitFieldInsn(kind == OwnerKind.NAMESPACE ? PUTSTATIC : PUTFIELD,
typeMapper.getOwner(propertyDescriptor, kind, isCallInsideSameModuleAsDeclared(propertyDescriptor, context)).getInternalName(),
propertyDescriptor.getName().getName(),
propertyDescriptor.getName().asString(),
type.getDescriptor());
iv.visitInsn(RETURN);
@@ -336,11 +336,11 @@ public class PropertyCodegen extends GenerationStateAware {
}
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) {
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) {
@@ -112,7 +112,7 @@ public class RangeCodegenUtil {
}
public static boolean isOptimizableRangeTo(CallableDescriptor rangeTo) {
if ("rangeTo".equals(rangeTo.getName().getName())) {
if ("rangeTo".equals(rangeTo.getName().asString())) {
if (isPrimitiveNumberClassDescriptor(rangeTo.getContainingDeclaration())) {
return true;
}
@@ -913,7 +913,7 @@ public abstract class StackValue {
}
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) {
String base = peekFromStack(nameStack);
return DescriptorUtils.isTopLevelDeclaration(classDescriptor) ? base.isEmpty() ? classDescriptor.getName()
.getName() : base + '/' + classDescriptor.getName() : base + '$' + classDescriptor.getName();
.asString() : base + '/' + classDescriptor.getName() : base + '$' + classDescriptor.getName();
}
@Override
@@ -350,7 +350,7 @@ class CodegenAnnotatingVisitor extends JetVisitorVoid {
DeclarationDescriptor containingDeclaration = descriptor.getContainingDeclaration();
String peek = peekFromStack(nameStack);
String name = descriptor.getName().getName();
String name = descriptor.getName().asString();
if (containingDeclaration instanceof ClassDescriptor) {
return peek + '$' + name;
}
@@ -116,7 +116,7 @@ public final class PsiCodegenPredictor {
if (declaration instanceof JetNamedFunction) {
if (parentDeclaration == null) {
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)) {
@@ -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
// namespace$propertyName$ClassName
if (declaration instanceof JetProperty) {
return JvmClassName.byInternalName(parentClassName.getInternalName() + "$" + name.getName());
return JvmClassName.byInternalName(parentClassName.getInternalName() + "$" + name.asString());
}
if (fqName.isRoot()) {
return JvmClassName.byInternalName(name.getName());
return JvmClassName.byInternalName(name.asString());
}
return JvmClassName.byInternalName(parentDeclaration == null ?
parentClassName.getInternalName() + "/" + name.getName() :
parentClassName.getInternalName() + "$" + name.getName());
parentClassName.getInternalName() + "/" + name.asString() :
parentClassName.getInternalName() + "$" + name.asString());
}
return null;
@@ -241,7 +241,7 @@ public class IntrinsicMethods {
for (AnnotationDescriptor annotation : annotations) {
ClassifierDescriptor classifierDescriptor = annotation.getType().getConstructor().getDeclarationDescriptor();
assert classifierDescriptor != null;
if ("Intrinsic".equals(classifierDescriptor.getName().getName())) {
if ("Intrinsic".equals(classifierDescriptor.getName().asString())) {
String value = (String) annotation.getAllValueArguments().values().iterator().next().getValue();
intrinsicMethod = namedMethods.get(value);
if (intrinsicMethod != null) {
@@ -51,7 +51,7 @@ public class StaticField implements IntrinsicMethod {
StackValue receiver,
@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);
}
}
@@ -272,8 +272,8 @@ public class BothSignatureWriter {
}
public void writeTypeVariable(Name name, boolean nullable, Type asmType) {
signatureVisitor().visitTypeVariable(name.getName());
jetSignatureWriter.visitTypeVariable(name.getName(), nullable);
signatureVisitor().visitTypeVariable(name.asString());
jetSignatureWriter.visitTypeVariable(name.asString(), nullable);
generic = true;
writeAsmType0(asmType);
}
@@ -578,7 +578,7 @@ public class JetTypeMapper extends BindingTraceAware {
@NotNull
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) {
boolean isGetter = f instanceof PropertyGetterDescriptor;
name = getPropertyAccessorName(((PropertyAccessorDescriptor) f).getCorrespondingProperty(), isGetter);
@@ -588,7 +588,7 @@ public class JetTypeMapper extends BindingTraceAware {
@NotNull
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
@@ -675,7 +675,7 @@ public class JetTypeMapper extends BindingTraceAware {
}
private void writeFormalTypeParameter(TypeParameterDescriptor typeParameterDescriptor, BothSignatureWriter signatureVisitor) {
signatureVisitor.writeFormalTypeParameter(typeParameterDescriptor.getName().getName(), typeParameterDescriptor.getVariance(),
signatureVisitor.writeFormalTypeParameter(typeParameterDescriptor.getName().asString(), typeParameterDescriptor.getVariance(),
typeParameterDescriptor.isReified());
classBound:
@@ -730,7 +730,7 @@ public class JetTypeMapper extends BindingTraceAware {
DeclarationDescriptor parentDescriptor = descriptor.getContainingDeclaration();
boolean isAnnotation = parentDescriptor instanceof ClassDescriptor &&
((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());
}
@@ -109,7 +109,7 @@ public final class AnalyzerWithCompilerReport {
if (!incompletes.isEmpty()) {
StringBuilder message = new StringBuilder("The following classes have incomplete hierarchies:\n");
for (ClassDescriptor incomplete : incompletes) {
String fqName = DescriptorUtils.getFQName(incomplete).getFqName();
String fqName = DescriptorUtils.getFQName(incomplete).asString();
message.append(" ").append(fqName).append("\n");
}
messageCollectorWrapper.report(CompilerMessageSeverity.ERROR, message.toString(), CompilerMessageLocation.NO_LOCATION);
@@ -203,7 +203,7 @@ public class CompileEnvironmentUtil {
mainAttributes.putValue("Manifest-Version", "1.0");
mainAttributes.putValue("Created-By", "JetBrains Kotlin");
if (mainClass != null) {
mainAttributes.putValue("Main-Class", mainClass.getFqName());
mainAttributes.putValue("Main-Class", mainClass.asString());
}
JarOutputStream stream = new JarOutputStream(fos, manifest);
for (String file : factory.files()) {
@@ -236,7 +236,7 @@ public class ReplInterpreter {
}
try {
Class<?> scriptClass = classLoader.loadClass(scriptClassName.getFqName().getFqName());
Class<?> scriptClass = classLoader.loadClass(scriptClassName.getFqName().asString());
Class<?>[] constructorParams = new Class<?>[earlierLines.size()];
Object[] constructorArgs = new Object[earlierLines.size()];
@@ -140,7 +140,7 @@ public final class DescriptorResolverUtils {
public static FqNameUnsafe getFqNameForClassObject(@NotNull PsiClass psiClass) {
String psiClassQualifiedName = psiClass.getQualifiedName();
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
@@ -65,7 +65,7 @@ public class JavaToKotlinClassMap extends JavaToKotlinClassMapBuilder implements
PrimitiveType primitiveType = jvmPrimitiveType.getPrimitiveType();
primitiveTypesMap.put(jvmPrimitiveType.getName(), KotlinBuiltIns.getInstance().getPrimitiveJetType(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));
}
primitiveTypesMap.put("void", KotlinBuiltIns.getInstance().getUnitType());
@@ -91,7 +91,7 @@ public class JavaToKotlinClassMap extends JavaToKotlinClassMapBuilder implements
@Nullable
public AnnotationDescriptor mapToAnnotationClass(@NotNull FqName 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 null;
@@ -184,7 +184,7 @@ public class JavaTypeTransformer {
" in " + classType.getPresentableText() + "\n PsiClass: \n" + psiClass.getText());
for (TypeParameterDescriptor parameter : parameters) {
arguments.add(new TypeProjection(ErrorUtils.createErrorType(parameter.getName().getName())));
arguments.add(new TypeProjection(ErrorUtils.createErrorType(parameter.getName().asString())));
}
}
else {
@@ -275,10 +275,10 @@ public class JavaTypeTransformer {
if (!signatureTypeUsages.contains(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;
}
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 originalTypeUsage;
@@ -86,7 +86,7 @@ public abstract class JetTypeJetSignatureReader extends JetSignatureExceptionsAd
public void visitClassType(String signatureName, boolean nullable, boolean forceReal) {
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) {
@@ -17,8 +17,6 @@
package org.jetbrains.jet.lang.resolve.java;
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.Name;
@@ -58,7 +56,7 @@ public class JvmAbi {
}
public static String getPropertyDelegateName(@NotNull Name name) {
return name.getName() + DELEGATED_PROPERTY_NAME_POSTFIX;
return name.asString() + DELEGATED_PROPERTY_NAME_POSTFIX;
}
private JvmAbi() {
@@ -91,7 +91,7 @@ public class JvmClassName {
List<String> innerClassNames = Lists.newArrayList();
while (descriptor.getContainingDeclaration() instanceof ClassDescriptor) {
innerClassNames.add(descriptor.getName().getName());
innerClassNames.add(descriptor.getName().asString());
descriptor = descriptor.getContainingDeclaration();
assert descriptor != null;
}
@@ -101,7 +101,7 @@ public class JvmClassName {
@NotNull
private static String fqNameToInternalName(@NotNull FqName fqName) {
return fqName.getFqName().replace('.', '/');
return fqName.asString().replace('.', '/');
}
@NotNull
@@ -122,6 +122,6 @@ public class KotlinToJavaTypesMap extends JavaToKotlinClassMapBuilder {
public boolean isForceReal(@NotNull JvmClassName className) {
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()) {
return DEFAULT_PACKAGE;
}
return StringUtil.capitalize(packageFQN.shortName().getName()) + "Package";
return StringUtil.capitalize(packageFQN.shortName().asString()) + "Package";
}
public static FqName getPackageClassFqName(@NotNull FqName packageFQN) {
@@ -86,7 +86,7 @@ public class PsiClassFinderImpl implements PsiClassFinder {
@Override
@Nullable
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) {
String classQualifiedName = original.getQualifiedName();
@@ -106,7 +106,7 @@ public class PsiClassFinderImpl implements PsiClassFinder {
if (KotlinBuiltIns.BUILT_INS_PACKAGE_FQ_NAME.equals(qualifiedName.parent())) {
PsiAnnotation assertInvisibleAnnotation = JavaAnnotationResolver.findOwnAnnotation(
original, JvmStdlibNames.ASSERT_INVISIBLE_IN_RESOLVER.getFqName().getFqName());
original, JvmStdlibNames.ASSERT_INVISIBLE_IN_RESOLVER.getFqName().asString());
if (assertInvisibleAnnotation != null) {
switch (runtimeClassesHandleMode) {
@@ -131,7 +131,7 @@ public class PsiClassFinderImpl implements PsiClassFinder {
@Override
@Nullable
public PsiPackage findPsiPackage(@NotNull FqName qualifiedName) {
return javaFacade.findPackage(qualifiedName.getFqName());
return javaFacade.findPackage(qualifiedName.asString());
}
@NotNull
@@ -60,7 +60,7 @@ public class TypeVariableResolverFromTypeDescriptors implements TypeVariableReso
@NotNull DeclarationDescriptor owner,
@NotNull String context) {
for (TypeParameterDescriptor typeParameter : typeParameters) {
if (typeParameter.getName().getName().equals(name)) {
if (typeParameter.getName().asString().equals(name)) {
return typeParameter;
}
}
@@ -254,7 +254,7 @@ public class SignaturesPropagationData {
public int compare(FunctionDescriptor fun1, FunctionDescriptor fun2) {
FqNameUnsafe fqName1 = getFQName(fun1.getContainingDeclaration());
FqNameUnsafe fqName2 = getFQName(fun2.getContainingDeclaration());
return fqName1.getFqName().compareTo(fqName2.getFqName());
return fqName1.asString().compareTo(fqName2.asString());
}
});
return superFunctions;
@@ -99,14 +99,14 @@ public class TypeTransformingVisitor extends JetVisitor<JetType, Void> {
}
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) {
TypeConstructor originalTypeConstructor = originalType.getConstructor();
ClassifierDescriptor declarationDescriptor = originalTypeConstructor.getDeclarationDescriptor();
assert declarationDescriptor != null;
String fqName = DescriptorUtils.getFQName(declarationDescriptor).toSafe().getFqName();
String fqName = DescriptorUtils.getFQName(declarationDescriptor).toSafe().asString();
ClassDescriptor classFromLibrary = getAutoTypeAnalogWithinBuiltins(qualifiedName);
if (!isSameName(qualifiedName, fqName) && classFromLibrary == null) {
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 =
JavaToKotlinClassMap.getInstance().mapPlatformClass(JvmClassName.byType(javaAnalog).getFqName());
for (ClassDescriptor descriptor : descriptors) {
String fqName = DescriptorUtils.getFQName(descriptor).getFqName();
String fqName = DescriptorUtils.getFQName(descriptor).asString();
if (isSameName(qualifiedName, fqName)) {
return descriptor;
}
@@ -54,7 +54,7 @@ public class JetClassAnnotation extends PsiAnnotationWithAbiVersion {
@NotNull
public static JetClassAnnotation get(PsiClass psiClass) {
PsiAnnotation annotation = JavaAnnotationResolver.findOwnAnnotation(psiClass,
JvmStdlibNames.JET_CLASS.getFqName().getFqName());
JvmStdlibNames.JET_CLASS.getFqName().asString());
return annotation != null ? new JetClassAnnotation(annotation) : NULL_ANNOTATION;
}
}
@@ -38,7 +38,7 @@ public class JetClassObjectAnnotation extends PsiAnnotationWithAbiVersion {
@NotNull
public static JetClassObjectAnnotation get(@NotNull PsiClass psiClass) {
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;
}
}
@@ -48,7 +48,7 @@ public class JetConstructorAnnotation extends PsiAnnotationWithFlags {
public static JetConstructorAnnotation get(PsiMethod constructor) {
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;
}
}
@@ -69,7 +69,7 @@ public class JetMethodAnnotation extends PsiAnnotationWithFlags {
public static JetMethodAnnotation get(PsiMethod psiMethod) {
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;
}
}
@@ -36,7 +36,7 @@ public class JetPackageClassAnnotation extends PsiAnnotationWithAbiVersion {
@NotNull
public static JetPackageClassAnnotation get(PsiClass 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;
}
}
@@ -40,7 +40,7 @@ public class JetTypeParameterAnnotation extends PsiAnnotationWrapper {
@NotNull
public static JetTypeParameterAnnotation get(@NotNull PsiParameter psiParameter) {
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;
}
}
@@ -77,7 +77,7 @@ public class JetValueParameterAnnotation extends PsiAnnotationWrapper {
public static JetValueParameterAnnotation get(PsiParameter psiParameter) {
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;
}
}
@@ -50,7 +50,7 @@ public class KotlinSignatureAnnotation extends PsiAnnotationWrapper {
@NotNull
public static KotlinSignatureAnnotation get(PsiModifierListOwner psiModifierListOwner) {
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;
}
}
@@ -413,7 +413,7 @@ public final class MembersCache {
return null;
}
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;
}
if (!psiClass.isInterface() || psiClass.isAnnotationType()) {
@@ -84,7 +84,7 @@ public final class JavaAnnotationResolver {
}
// 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;
}
@@ -131,7 +131,7 @@ public final class JavaClassObjectResolver {
ClassDescriptorFromJvmBytecode classObjectDescriptor =
new ClassDescriptorFromJvmBytecode(containing, ClassKind.CLASS_OBJECT, false);
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;
}
@@ -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.Name;
import org.jetbrains.jet.lang.types.JetType;
import org.jetbrains.jet.lang.types.TypeSubstitutor;
import org.jetbrains.jet.lang.types.TypeUtils;
import javax.inject.Inject;
@@ -203,7 +202,7 @@ public final class JavaClassResolver {
private static boolean isTraitImplementation(@NotNull FqName qualifiedName) {
// 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
@@ -295,7 +294,7 @@ public final class JavaClassResolver {
String containerQualifiedName = methodContainer.getQualifiedName();
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 =
functionResolver.resolveFunctionMutely(new PsiMethodWrapper(samInterfaceMethod), samInterface);
assert abstractMethod != null : "couldn't resolve method " + samInterfaceMethod;
@@ -378,7 +377,7 @@ public final class JavaClassResolver {
private static FqNameUnsafe javaClassToKotlinFqName(@NotNull FqName rawFqName) {
List<Name> correctedSegments = new ArrayList<Name>();
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();
Name previous = correctedSegments.get(correctedSegments.size() - 1);
correctedSegments.add(DescriptorUtils.getClassObjectName(previous));
@@ -125,7 +125,7 @@ public final class JavaFunctionResolver {
// TODO: unless maybe class explicitly extends Object
assert containingClass != null;
String ownerClassName = containingClass.getQualifiedName();
if (DescriptorResolverUtils.OBJECT_FQ_NAME.getFqName().equals(ownerClassName)) {
if (DescriptorResolverUtils.OBJECT_FQ_NAME.asString().equals(ownerClassName)) {
return null;
}
}
@@ -439,7 +439,7 @@ public final class JavaFunctionResolver {
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) {
return TypeUtils.makeNullableAsSpecified(transformedType, false);
}
@@ -392,7 +392,7 @@ public final class JavaPropertyResolver {
boolean hasNotNullAnnotation = JavaAnnotationResolver.findAnnotationWithExternal(
characteristicMember.getType().getPsiNotNullOwner(),
JvmAbi.JETBRAINS_NOT_NULL_ANNOTATION.getFqName().getFqName()) != null;
JvmAbi.JETBRAINS_NOT_NULL_ANNOTATION.getFqName().asString()) != null;
if (hasNotNullAnnotation || members.isStaticFinalField()) {
propertyType = TypeUtils.makeNotNullable(propertyType);
@@ -90,7 +90,7 @@ public final class JavaValueParameterResolver {
else {
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) {
transformedType = TypeUtils.makeNullableAsSpecified(outType, false);
}
@@ -73,7 +73,7 @@ public class ClassDescriptorImpl extends DeclarationDescriptorNonRootImpl implem
@Nullable ConstructorDescriptor primaryConstructor,
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.constructors = constructors;
this.primaryConstructor = primaryConstructor;
@@ -109,7 +109,7 @@ public abstract class MutableClassDescriptorLite extends ClassDescriptorBase {
this,
Collections.<AnnotationDescriptor>emptyList(), // TODO : pass annotations from the class?
!getModality().isOverridable(),
getName().getName(),
getName().asString(),
typeParameters,
supertypes);
}
@@ -91,7 +91,7 @@ public class TypeParameterDescriptorImpl extends DeclarationDescriptorNonRootImp
this,
annotations,
false,
name.getName(),
name.asString(),
Collections.<TypeParameterDescriptor>emptyList(),
upperBounds);
}
@@ -64,7 +64,7 @@ public class Renderers {
@Override
public String render(@NotNull Object element) {
if (element instanceof Named) {
return ((Named) element).getName().getName();
return ((Named) element).getName().asString();
}
return element.toString();
}
@@ -299,7 +299,7 @@ public class Renderers {
StringBuilder sb = new StringBuilder();
int index = 0;
for (ClassDescriptor descriptor : descriptors) {
sb.append(DescriptorUtils.getFQName(descriptor).getFqName());
sb.append(DescriptorUtils.getFQName(descriptor).asString());
index++;
if (index <= descriptors.size() - 2) {
sb.append(", ");
@@ -199,7 +199,7 @@ public class JetClass extends JetTypeParameterListOwnerStub<PsiJetClassStub> imp
PsiJetClassStub stub = getStub();
if (stub != null) {
FqName fqName = stub.getFqName();
return fqName == null ? null : fqName.getFqName();
return fqName == null ? null : fqName.asString();
}
List<String> parts = new ArrayList<String>();
@@ -228,7 +228,7 @@ public class JetPsiFactory {
Name alias = importPath.getAlias();
if (alias != null) {
importDirectiveBuilder.append(" as ").append(alias.getName());
importDirectiveBuilder.append(" as ").append(alias.asString());
}
JetFile namespace = createFile(project, importDirectiveBuilder.toString());
@@ -408,7 +408,7 @@ public class JetPsiUtil {
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) {
@@ -694,7 +694,7 @@ public class JetPsiUtil {
public static boolean checkVariableDeclarationInBlock(@NotNull JetBlockExpression block, @NotNull String varName) {
for (JetElement element : block.getStatements()) {
if (element instanceof JetVariableDeclaration) {
if (((JetVariableDeclaration) element).getNameAsSafeName().getName().equals(varName)) {
if (((JetVariableDeclaration) element).getNameAsSafeName().asString().equals(varName)) {
return true;
}
}
@@ -50,7 +50,7 @@ public class JetAnnotationElementType extends JetStubElementType<PsiJetAnnotatio
@Override
public PsiJetAnnotationStub createStub(@NotNull JetAnnotationEntry psi, StubElement parentStub) {
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);
}
@@ -54,7 +54,7 @@ public class JetClassElementType extends JetStubElementType<PsiJetClassStub, Jet
public PsiJetClassStub createStub(@NotNull JetClass psi, StubElement parentStub) {
FqName fqName = JetPsiUtil.getFQName(psi);
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());
}
@@ -62,7 +62,7 @@ public class JetClassElementType extends JetStubElementType<PsiJetClassStub, Jet
public void serialize(PsiJetClassStub stub, StubOutputStream dataStream) throws IOException {
dataStream.writeName(stub.getName());
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.isEnumClass());
dataStream.writeBoolean(stub.isEnumEntry());
@@ -93,11 +93,11 @@ public class AnnotationResolver {
ConstructorDescriptor constructor = (ConstructorDescriptor)descriptor;
ClassDescriptor classDescriptor = constructor.getContainingDeclaration();
if (classDescriptor.getKind() != ClassKind.ANNOTATION_CLASS) {
trace.report(Errors.NOT_AN_ANNOTATION_CLASS.on(entryElement, classDescriptor.getName().getName()));
trace.report(Errors.NOT_AN_ANNOTATION_CLASS.on(entryElement, classDescriptor.getName().asString()));
}
}
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();
@@ -313,7 +313,7 @@ public class DeclarationResolver {
for (PsiElement declaration : getDeclarationsByDescriptor(declarationDescriptor)) {
assert declaration != null : "Null declaration for descriptor: " + 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) {
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 inAbstractClass = classDescriptor.getModality() == Modality.ABSTRACT;
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) {
trace.report(ABSTRACT_MODIFIER_IN_TRAIT.on(function));
@@ -363,7 +363,7 @@ public class DescriptorUtils {
@NotNull
public static Name getClassObjectName(@NotNull Name className) {
return getClassObjectName(className.getName());
return getClassObjectName(className.asString());
}
@NotNull
@@ -405,7 +405,7 @@ public class DescriptorUtils {
String typeSuffix = rendererForTypesIfNecessary == null
? ""
: ": " + 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);
return resultList;
@@ -536,14 +536,14 @@ public class DescriptorUtils {
public static boolean isEnumValueOfMethod(@NotNull FunctionDescriptor functionDescriptor) {
List<ValueParameterDescriptor> methodTypeParameters = functionDescriptor.getValueParameters();
JetType nullableString = TypeUtils.makeNullable(KotlinBuiltIns.getInstance().getStringType());
return "valueOf".equals(functionDescriptor.getName().getName())
return "valueOf".equals(functionDescriptor.getName().asString())
&& methodTypeParameters.size() == 1
&& JetTypeChecker.INSTANCE.isSubtypeOf(methodTypeParameters.get(0).getType(), nullableString);
}
public static boolean isEnumValuesMethod(@NotNull FunctionDescriptor functionDescriptor) {
List<ValueParameterDescriptor> methodTypeParameters = functionDescriptor.getValueParameters();
return "values".equals(functionDescriptor.getName().getName())
return "values".equals(functionDescriptor.getName().asString())
&& methodTypeParameters.isEmpty();
}
@@ -50,12 +50,12 @@ public final class ImportPath {
}
public String getPathStr() {
return fqName.getFqName() + (isAllUnder ? ".*" : "");
return fqName.asString() + (isAllUnder ? ".*" : "");
}
@Override
public String toString() {
return getPathStr() + (alias != null ? " as " + alias.getName() : "");
return getPathStr() + (alias != null ? " as " + alias.asString() : "");
}
@NotNull
@@ -75,7 +75,7 @@ public class OverloadResolver {
}
Key(NamespaceDescriptor namespaceDescriptor, Name name) {
this(DescriptorUtils.getFQName(namespaceDescriptor).getFqName(), name);
this(DescriptorUtils.getFQName(namespaceDescriptor).asString(), name);
}
public String getNamespace() {
@@ -149,7 +149,7 @@ public class OverloadResolver {
}
if (jetClass instanceof JetObjectDeclaration) {
// must be class object
name = classDescriptor.getContainingDeclaration().getName().getName();
name = classDescriptor.getContainingDeclaration().getName().asString();
return "class object " + name;
}
// safe
@@ -223,7 +223,7 @@ public class OverloadResolver {
CallableMemberDescriptor memberDescriptor = redeclaration.getSecond();
JetDeclaration jetDeclaration = redeclaration.getFirst();
if (memberDescriptor instanceof PropertyDescriptor) {
trace.report(Errors.REDECLARATION.on(jetDeclaration, memberDescriptor.getName().getName()));
trace.report(Errors.REDECLARATION.on(jetDeclaration, memberDescriptor.getName().asString()));
}
else {
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) {
JetDeclaration declaration = (JetDeclaration) BindingContextUtils
.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) {
if (declared.getKind() == CallableMemberDescriptor.Kind.SYNTHESIZED) {
// 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);
}
return;
@@ -39,7 +39,7 @@ public class TraceBasedRedeclarationHandler implements RedeclarationHandler {
private void report(DeclarationDescriptor descriptor) {
PsiElement firstElement = BindingContextUtils.descriptorToDeclaration(trace.getBindingContext(), descriptor);
if (firstElement != null) {
trace.report(REDECLARATION.on(firstElement, descriptor.getName().getName()));
trace.report(REDECLARATION.on(firstElement, descriptor.getName().asString()));
}
else {
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;
ClassifierDescriptor declarationDescriptor = constructor.getDeclarationDescriptor();
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);
}
@@ -51,7 +51,6 @@ import org.jetbrains.jet.lexer.JetTokens;
import javax.inject.Inject;
import java.util.Collection;
import java.util.Collections;
import java.util.EnumSet;
import java.util.List;
import static org.jetbrains.jet.lang.descriptors.ReceiverParameterDescriptor.NO_RECEIVER_PARAMETER;
@@ -100,7 +99,7 @@ public class CallResolver {
Name referencedName = nameExpression.getReferencedNameAsName();
List<CallableDescriptorCollector<? extends VariableDescriptor>> callableDescriptorCollectors = Lists.newArrayList();
if (nameExpression.getReferencedNameElementType() == JetTokens.FIELD_IDENTIFIER) {
referencedName = Name.identifier(referencedName.getName().substring(1));
referencedName = Name.identifier(referencedName.asString().substring(1));
callableDescriptorCollectors.add(CallableDescriptorCollectors.PROPERTIES);
}
else {
@@ -178,7 +178,7 @@ public class TracingStrategyImpl implements TracingStrategy {
JetExpression left = binaryExpression.getLeft();
JetExpression right = binaryExpression.getRight();
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 {
@@ -124,7 +124,7 @@ public class LazyClassMemberScope extends AbstractLazyMemberScope<LazyClassDescr
fromCurrent);
assert declaration != null : "fromCurrent can not be a fake override";
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() {
if (!isValidAfterUnsafeCheck(fqName.getFqName())) {
if (!isValidAfterUnsafeCheck(fqName.asString())) {
throw new IllegalArgumentException("incorrect fq name: " + fqName);
}
}
@@ -71,8 +71,8 @@ public class FqName extends FqNameBase {
@Override
@NotNull
public String getFqName() {
return fqName.getFqName();
public String asString() {
return fqName.asString();
}
@NotNull
@@ -27,7 +27,7 @@ public abstract class FqNameBase {
}
@NotNull
protected abstract String getFqName();
protected abstract String asString();
@NotNull
private FqNameUnsafe toFqNameUnsafe() {
@@ -51,6 +51,6 @@ public abstract class FqNameBase {
}
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
public String getFqName() {
public String asString() {
return fqName;
}
@@ -93,7 +93,7 @@ public class FqNameUnsafe extends FqNameBase {
if (safe != null) {
return true;
}
return FqName.isValidAfterUnsafeCheck(getFqName());
return FqName.isValidAfterUnsafeCheck(asString());
}
@NotNull
@@ -128,10 +128,10 @@ public class FqNameUnsafe extends FqNameBase {
public FqNameUnsafe child(@NotNull Name name) {
String childFqName;
if (isRoot()) {
childFqName = name.getName();
childFqName = name.asString();
}
else {
childFqName = fqName + "." + name.getName();
childFqName = fqName + "." + name.asString();
}
return new FqNameUnsafe(childFqName, this, name);
}
@@ -210,7 +210,7 @@ public class FqNameUnsafe extends FqNameBase {
}
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);
while (true) {
@@ -254,13 +254,13 @@ public class FqNameUnsafe extends FqNameBase {
@NotNull
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
public String toString() {
return isRoot() ? ROOT_NAME.getName() : fqName;
return isRoot() ? ROOT_NAME.asString() : fqName;
}
@Override
@@ -29,7 +29,7 @@ public final class Name implements Comparable<Name> {
}
@NotNull
public String getName() {
public String asString() {
return name;
}
@@ -38,7 +38,7 @@ public final class Name implements Comparable<Name> {
if (special) {
throw new IllegalStateException("not identifier: " + this);
}
return getName();
return asString();
}
public boolean isSpecial() {
@@ -176,7 +176,7 @@ public class WritableScopeImpl extends WritableScopeWithImports {
checkMayWrite();
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);
if (declarationDescriptors == null) {
declarationDescriptors = new ArrayList<DeclarationDescriptor>();
@@ -481,7 +481,7 @@ public class WritableScopeImpl extends WritableScopeWithImports {
public PropertyDescriptor getPropertyByFieldReference(@NotNull Name fieldName) {
checkMayRead();
if (!fieldName.getName().startsWith("$")) {
if (!fieldName.asString().startsWith("$")) {
throw new IllegalStateException();
}
@@ -792,13 +792,13 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
if (operationType == JetTokens.PLUSPLUS || operationType == JetTokens.MINUSMINUS) {
assert returnType != null : "returnType is null for " + resolutionResults.getResultingDescriptor();
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));
}
else {
JetType receiverType = receiver.getType();
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 {
context.trace.record(BindingContext.VARIABLE_REASSIGNMENT, expression);
@@ -339,7 +339,7 @@ public class ControlStructureTypingVisitor extends ExpressionTypingVisitor {
VariableDescriptor olderVariable = context.scope.getLocalVariable(variableDescriptor.getName());
if (olderVariable != null && DescriptorUtils.isLocal(context.scope.getContainingDeclaration(), olderVariable)) {
PsiElement declaration = BindingContextUtils.descriptorToDeclaration(context.trace.getBindingContext(), variableDescriptor);
context.trace.report(Errors.NAME_SHADOWING.on(declaration, variableDescriptor.getName().getName()));
context.trace.report(Errors.NAME_SHADOWING.on(declaration, variableDescriptor.getName().asString()));
}
}
return variableDescriptor;
@@ -136,7 +136,7 @@ public class DelegatedPropertyUtils {
List<JetExpression> arguments = Lists.newArrayList();
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) {
JetReferenceExpression fakeArgument = (JetReferenceExpression) createFakeExpressionOfType(context.expressionTypingServices.getProject(), trace,
@@ -148,7 +148,7 @@ public class DelegatedPropertyUtils {
}
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);
call = CallMaker.makeCallWithExpressions(fakeCalleeExpression, receiver, null, fakeCalleeExpression, arguments, Call.CallType.DEFAULT);
@@ -237,7 +237,7 @@ public class ExpressionTypingUtils {
@NotNull JetScope scope,
@NotNull ModuleDescriptor module
) {
JetImportDirective importDirective = JetPsiFactory.createImportDirective(project, callableFQN.getFqName());
JetImportDirective importDirective = JetPsiFactory.createImportDirective(project, callableFQN.asString());
Collection<? extends DeclarationDescriptor> declarationDescriptors = new QualifiedExpressionResolver()
.analyseImportReference(importDirective, scope, new BindingTraceContext(), module);
@@ -436,7 +436,7 @@ public class ExpressionTypingUtils {
if (oldDescriptor != null && DescriptorUtils.isLocal(variableDescriptor.getContainingDeclaration(), oldDescriptor)) {
PsiElement declaration = BindingContextUtils.descriptorToDeclaration(context.trace.getBindingContext(), variableDescriptor);
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) {
ClassDescriptor theClass = getBuiltInClassByName(primitiveType.getTypeName().getName());
ClassDescriptor theClass = getBuiltInClassByName(primitiveType.getTypeName().asString());
JetType type = new JetTypeImpl(theClass);
ClassDescriptor arrayClass = getBuiltInClassByName(primitiveType.getArrayTypeName().getName());
ClassDescriptor arrayClass = getBuiltInClassByName(primitiveType.getArrayTypeName().asString());
JetType arrayType = new JetTypeImpl(arrayClass);
primitiveTypeToClass.put(primitiveType, theClass);
@@ -335,7 +335,7 @@ public class KotlinBuiltIns {
@NotNull
public ClassDescriptor getPrimitiveClassDescriptor(@NotNull PrimitiveType type) {
return getBuiltInClassByName(type.getTypeName().getName());
return getBuiltInClassByName(type.getTypeName().asString());
}
@NotNull
@@ -398,7 +398,7 @@ public class KotlinBuiltIns {
@NotNull
public ClassDescriptor getPrimitiveArrayClassDescriptor(@NotNull PrimitiveType type) {
return getBuiltInClassByName(type.getArrayTypeName().getName());
return getBuiltInClassByName(type.getArrayTypeName().asString());
}
@NotNull
@@ -39,8 +39,8 @@ public final class QualifiedNamesUtil {
return true;
}
String subpackageNameStr = subpackageName.getFqName();
String packageNameStr = packageName.getFqName();
String subpackageNameStr = subpackageName.asString();
String packageNameStr = packageName.asString();
return (subpackageNameStr.startsWith(packageNameStr) && subpackageNameStr.charAt(packageNameStr.length()) == '.');
}
@@ -54,7 +54,7 @@ public final class QualifiedNamesUtil {
}
public static boolean isOneSegmentFQN(@NotNull FqName fqn) {
return isOneSegmentFQN(fqn.getFqName());
return isOneSegmentFQN(fqn.asString());
}
@NotNull
@@ -74,7 +74,7 @@ public final class QualifiedNamesUtil {
return FqName.ROOT;
}
String fqNameStr = fqName.getFqName();
String fqNameStr = fqName.asString();
return new FqName(fqNameStr.substring(fqNameStr.indexOf('.'), fqNameStr.length()));
}
@@ -93,12 +93,12 @@ public final class QualifiedNamesUtil {
@NotNull
public static String tail(@NotNull FqName headFQN, @NotNull FqName fullFQN) {
if (!isSubpackageOf(fullFQN, headFQN) || headFQN.isRoot()) {
return fullFQN.getFqName();
return fullFQN.asString();
}
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;
public JetLightPackage(PsiManager manager, FqName qualifiedName, GlobalSearchScope scope) {
super(manager, qualifiedName.getFqName());
super(manager, qualifiedName.asString());
this.fqName = qualifiedName;
this.scope = scope;
}
@@ -189,7 +189,7 @@ public class KotlinJavaFileStubProvider implements CachedValueProvider<PsiJavaFi
private PsiJavaFileStub createJavaFileStub(@NotNull final FqName packageFqName, @NotNull VirtualFile virtualFile) {
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());
ClsFileImpl fakeFile =
@@ -203,7 +203,7 @@ public class KotlinJavaFileStubProvider implements CachedValueProvider<PsiJavaFi
@NotNull
@Override
public String getPackageName() {
return packageFqName.getFqName();
return packageFqName.asString();
}
};
@@ -175,7 +175,7 @@ public class KotlinLightClassForExplicitDeclaration extends AbstractLightClass i
@NotNull
@Override
public String getPackageName() {
return JetPsiUtil.getFQName((JetFile) classOrObject.getContainingFile()).getFqName();
return JetPsiUtil.getFQName((JetFile) classOrObject.getContainingFile()).asString();
}
@NotNull
@@ -260,13 +260,13 @@ public class KotlinLightClassForExplicitDeclaration extends AbstractLightClass i
@Nullable
@Override
public String getName() {
return classFqName.shortName().getName();
return classFqName.shortName().asString();
}
@Nullable
@Override
public String getQualifiedName() {
return classFqName.getFqName();
return classFqName.asString();
}
@NotNull
@@ -339,7 +339,7 @@ public class KotlinLightClassForExplicitDeclaration extends AbstractLightClass i
}
ClassDescriptor deprecatedAnnotation = KotlinBuiltIns.getInstance().getDeprecatedAnnotation();
String deprecatedName = deprecatedAnnotation.getName().getName();
String deprecatedName = deprecatedAnnotation.getName().asString();
FqNameUnsafe deprecatedFqName = DescriptorUtils.getFQName(deprecatedAnnotation);
for (JetAnnotationEntry annotationEntry : jetModifierList.getAnnotationEntries()) {
@@ -353,7 +353,7 @@ public class KotlinLightClassForExplicitDeclaration extends AbstractLightClass i
if (fqName == null) continue;
if (deprecatedFqName.equals(fqName.toUnsafe())) return true;
if (deprecatedName.equals(fqName.getFqName())) return true;
if (deprecatedName.equals(fqName.asString())) return true;
}
return false;
}
@@ -84,13 +84,13 @@ public class KotlinLightClassForPackage extends KotlinLightClassForPackageBase i
@Nullable
@Override
public String getName() {
return packageClassFqName.shortName().getName();
return packageClassFqName.shortName().asString();
}
@Nullable
@Override
public String getQualifiedName() {
return packageClassFqName.getFqName();
return packageClassFqName.asString();
}
@Override
@@ -99,7 +99,7 @@ public class LightClassUtil {
@Nullable
/*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();
}
@@ -222,7 +222,7 @@ public class LightClassUtil {
if (jvmName != null) {
Project project = declaration.getProject();
String fqName = jvmName.getFqName().getFqName();
String fqName = jvmName.getFqName().asString();
return JavaElementFinder.getInstance(project).findClass(fqName, GlobalSearchScope.allScope(project));
}
}
@@ -34,46 +34,46 @@ public class FqNameTest {
public void pathRoot() {
List<FqName> path = new FqName("").path();
Assert.assertEquals(1, path.size());
Assert.assertEquals("", path.get(0).getFqName());
Assert.assertEquals("", path.get(0).asString());
}
@Test
public void pathLevel1() {
List<FqName> path = new FqName("com").path();
Assert.assertEquals(2, path.size());
Assert.assertEquals("", path.get(0).getFqName());
Assert.assertEquals("com", path.get(1).getFqName());
Assert.assertEquals("com", path.get(1).shortName().getName());
Assert.assertEquals("", path.get(1).parent().getFqName());
Assert.assertEquals("", path.get(0).asString());
Assert.assertEquals("com", path.get(1).asString());
Assert.assertEquals("com", path.get(1).shortName().asString());
Assert.assertEquals("", path.get(1).parent().asString());
}
@Test
public void pathLevel2() {
List<FqName> path = new FqName("com.jetbrains").path();
Assert.assertEquals(3, path.size());
Assert.assertEquals("", path.get(0).getFqName());
Assert.assertEquals("com", path.get(1).getFqName());
Assert.assertEquals("com", path.get(1).shortName().getName());
Assert.assertEquals("", path.get(1).parent().getFqName());
Assert.assertEquals("com.jetbrains", path.get(2).getFqName());
Assert.assertEquals("jetbrains", path.get(2).shortName().getName());
Assert.assertEquals("com", path.get(2).parent().getFqName());
Assert.assertEquals("", path.get(0).asString());
Assert.assertEquals("com", path.get(1).asString());
Assert.assertEquals("com", path.get(1).shortName().asString());
Assert.assertEquals("", path.get(1).parent().asString());
Assert.assertEquals("com.jetbrains", path.get(2).asString());
Assert.assertEquals("jetbrains", path.get(2).shortName().asString());
Assert.assertEquals("com", path.get(2).parent().asString());
}
@Test
public void pathLevel3() {
List<FqName> path = new FqName("com.jetbrains.jet").path();
Assert.assertEquals(4, path.size());
Assert.assertEquals("", path.get(0).getFqName());
Assert.assertEquals("com", path.get(1).getFqName());
Assert.assertEquals("com", path.get(1).shortName().getName());
Assert.assertEquals("", path.get(1).parent().getFqName());
Assert.assertEquals("com.jetbrains", path.get(2).getFqName());
Assert.assertEquals("jetbrains", path.get(2).shortName().getName());
Assert.assertEquals("com", path.get(2).parent().getFqName());
Assert.assertEquals("com.jetbrains.jet", path.get(3).getFqName());
Assert.assertEquals("jet", path.get(3).shortName().getName());
Assert.assertEquals("com.jetbrains", path.get(3).parent().getFqName());
Assert.assertEquals("", path.get(0).asString());
Assert.assertEquals("com", path.get(1).asString());
Assert.assertEquals("com", path.get(1).shortName().asString());
Assert.assertEquals("", path.get(1).parent().asString());
Assert.assertEquals("com.jetbrains", path.get(2).asString());
Assert.assertEquals("jetbrains", path.get(2).shortName().asString());
Assert.assertEquals("com", path.get(2).parent().asString());
Assert.assertEquals("com.jetbrains.jet", path.get(3).asString());
Assert.assertEquals("jet", path.get(3).shortName().asString());
Assert.assertEquals("com.jetbrains", path.get(3).parent().asString());
}
@Test
@@ -84,7 +84,7 @@ public class FqNameTest {
List<Name> segments = new FqName(name).pathSegments();
List<String> segmentsStrings = new ArrayList<String>();
for (Name segment : segments) {
segmentsStrings.add(segment.getName());
segmentsStrings.add(segment.asString());
}
Assert.assertEquals(Arrays.asList(name.split("\\.")), segmentsStrings);
}
@@ -137,7 +137,7 @@ public abstract class CodegenTestCase extends UsefulTestCase {
@NotNull
protected Class<?> generateNamespaceClass() {
JvmClassName name = NamespaceCodegen.getJVMClassNameForKotlinNs(JetPsiUtil.getFQName(myFiles.getPsiFile()));
return generateClass(name.getFqName().getFqName());
return generateClass(name.getFqName().asString());
}
@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
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 {
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,
TEST_PACKAGE_FQNAME);
assert namespaceFromSource != null;
Assert.assertEquals("test", namespaceFromSource.getName().getName());
Assert.assertEquals("test", namespaceFromSource.getName().asString());
NamespaceDescriptor namespaceFromClass = LoadDescriptorUtil.loadTestNamespaceAndBindingContextFromJavaRoot(
tmpdir, getTestRootDisposable(), ConfigurationKind.JDK_ONLY).first;
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.renderer.DescriptorRenderer;
import java.io.File;
import java.util.*;
import static com.intellij.testFramework.UsefulTestCase.assertNotNull;
@@ -85,7 +84,7 @@ public class ExpectedLoadErrorsUtil {
ClassDescriptor annotationClass = (ClassDescriptor) annotation.getType().getConstructor().getDeclarationDescriptor();
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
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("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);
psiClass.accept(new JavaRecursiveElementVisitor() {
@@ -111,7 +111,7 @@ public class IdeaJdkAnnotationsReflectedTest extends KotlinTestWithEnvironment {
if (hasAnnotation(ideaFakeAnnotationsManager, ideaOwner, AnnotationUtil.NOT_NULL)) {
boolean kotlinHasNotNull = hasAnnotation(kotlinFakeAnnotationsManager, kotlinOwner, AnnotationUtil.NOT_NULL);
boolean kotlinHasKotlinSignature = hasAnnotation(kotlinFakeAnnotationsManager, kotlinOwner,
JvmStdlibNames.KOTLIN_SIGNATURE.getFqName().getFqName());
JvmStdlibNames.KOTLIN_SIGNATURE.getFqName().asString());
if (kotlinOwner == ideaOwner && kotlinHasNotNull || kotlinHasKotlinSignature) {
// good
}
@@ -61,8 +61,8 @@ public class JvmClassNameTest {
) {
JvmClassName mapEntryName = JvmClassName.bySignatureName(className);
assertEquals(innerClassName, mapEntryName.getInternalName());
assertEquals(fqName, mapEntryName.getFqName().getFqName());
assertEquals(outerClassName, mapEntryName.getOuterClassFqName().getFqName());
assertEquals(fqName, mapEntryName.getFqName().asString());
assertEquals(outerClassName, mapEntryName.getOuterClassFqName().asString());
assertEquals(innerClassNameList, mapEntryName.getInnerClassNameList());
}
}
@@ -131,7 +131,7 @@ public class NamespaceComparator {
private boolean shouldSkip(@NotNull DeclarationDescriptor subDescriptor) {
return subDescriptor.getContainingDeclaration() instanceof ClassDescriptor
&& subDescriptor instanceof FunctionDescriptor
&& JAVA_OBJECT_METHOD_NAMES.contains(subDescriptor.getName().getName())
&& JAVA_OBJECT_METHOD_NAMES.contains(subDescriptor.getName().asString())
&& !conf.includeMethodsOfJavaObject
||
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 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 {
CompilerConfiguration configuration = new CompilerConfiguration();
@@ -207,7 +207,7 @@ public class GenerateJavaToKotlinMethodMap {
private void appendBeforeClass(@NotNull ClassDescriptor kotlinClass, @NotNull PsiClass psiClass) {
String psiFqName = psiClass.getQualifiedName();
String kotlinFqName = DescriptorUtils.getFQName(kotlinClass).toSafe().getFqName();
String kotlinFqName = DescriptorUtils.getFQName(kotlinClass).toSafe().asString();
assert kotlinFqName.startsWith(BUILTINS_FQNAME_PREFIX);
String kotlinSubQualifiedName = kotlinFqName.substring(BUILTINS_FQNAME_PREFIX.length());
@@ -44,11 +44,11 @@ public class JetPluginUtil {
LinkedList<String> fullName = Lists.newLinkedList();
while (declarationDescriptor != null && !(declarationDescriptor instanceof ModuleDescriptor)) {
fullName.addFirst(declarationDescriptor.getName().getName());
fullName.addFirst(declarationDescriptor.getName().asString());
declarationDescriptor = declarationDescriptor.getContainingDeclaration();
}
assert fullName.size() > 0;
if (JavaDescriptorResolver.JAVA_ROOT.getName().equals(fullName.getFirst())) {
if (JavaDescriptorResolver.JAVA_ROOT.asString().equals(fullName.getFirst())) {
fullName.removeFirst();
}
return fullName;
@@ -107,7 +107,7 @@ public class JetAddImportAction implements QuestionAction {
return FINAL_CHOICE;
}
List<String> toExclude = AddImportAction.getAllExcludableStrings(selectedValue.getFqName());
List<String> toExclude = AddImportAction.getAllExcludableStrings(selectedValue.asString());
return new BaseListPopupStep<String>(null, toExclude) {
@NotNull
@@ -135,7 +135,7 @@ public class JetAddImportAction implements QuestionAction {
@NotNull
@Override
public String getTextFor(FqName value) {
return value.getFqName();
return value.asString();
}
@Override
@@ -39,7 +39,7 @@ public class JetGotoClassContributor implements GotoClassContributor {
JetNamedDeclaration jetClass = (JetNamedDeclaration) item;
FqName name = JetPsiUtil.getFQName(jetClass);
if (name != null) {
return name.getFqName();
return name.asString();
}
}
@@ -107,7 +107,7 @@ public class JetShortNamesCache extends PsiShortNamesCache {
Collection<FqName> fqNames = packageClasses.get(name);
if (!fqNames.isEmpty()) {
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) {
result.add(psiClass);
}
@@ -123,10 +123,10 @@ public class JetShortNamesCache extends PsiShortNamesCache {
for (JetClassOrObject classOrObject : classOrObjects) {
FqName fqName = JetPsiUtil.getFQName(classOrObject);
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" +
"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) {
result.add(psiClass);
}
@@ -230,7 +230,7 @@ public class JetShortNamesCache extends PsiShortNamesCache {
Set<FunctionDescriptor> result = Sets.newHashSet();
Collection<PsiMethod> topLevelFunctionPrototypes = JetFromJavaDescriptorHelper.getTopLevelFunctionPrototypesByName(
referenceName.getName(), project, scope);
referenceName.asString(), project, scope);
for (PsiMethod method : topLevelFunctionPrototypes) {
FqName functionFQN = JetFromJavaDescriptorHelper.getJetTopLevelDeclarationFQN(method);
if (functionFQN != null) {
@@ -246,7 +246,7 @@ public class JetShortNamesCache extends PsiShortNamesCache {
}
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) {
PsiFile containingFile = jetNamedFunction.getContainingFile();
if (containingFile instanceof JetFile) {
@@ -354,7 +354,7 @@ public class JetShortNamesCache extends PsiShortNamesCache {
for (String fqName : JetFullClassNameIndex.getInstance().getAllKeys(project)) {
FqName classFQName = new FqName(fqName);
if (acceptedShortNameCondition.value(classFQName.shortName().getName())) {
if (acceptedShortNameCondition.value(classFQName.shortName().asString())) {
classDescriptors.addAll(getJetClassesDescriptorsByFQName(analyzer, classFQName));
}
}
@@ -364,7 +364,7 @@ public class JetShortNamesCache extends PsiShortNamesCache {
private Collection<ClassDescriptor> getJetClassesDescriptorsByFQName(@NotNull KotlinCodeAnalyzer analyzer, @NotNull FqName classFQName) {
Collection<JetClassOrObject> jetClassOrObjects = JetFullClassNameIndex.getInstance().get(
classFQName.getFqName(), project, GlobalSearchScope.allScope(project));
classFQName.asString(), project, GlobalSearchScope.allScope(project));
if (jetClassOrObjects.isEmpty()) {
// 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.LightClassConstructionContext;
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.JetFile;
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.name.FqName;
import org.jetbrains.jet.plugin.libraries.JetSourceNavigationHelper;
@@ -70,13 +68,13 @@ public class IDELightClassGenerationSupport extends LightClassGenerationSupport
@NotNull
@Override
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
@Override
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>() {
@Override
public boolean value(JetFile file) {
@@ -90,20 +88,20 @@ public class IDELightClassGenerationSupport extends LightClassGenerationSupport
public Collection<JetClassOrObject> findClassOrObjectDeclarationsInPackage(
@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
public boolean packageExists(
@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
@Override
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();
for (JetFile file : files) {
@@ -141,7 +139,7 @@ public class IDELightClassGenerationSupport extends LightClassGenerationSupport
Collection<JetFile> files = findFilesForPackage(new FqName(packageFqName), scope);
if (!files.isEmpty()) {
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) {
String name = targetClass.getName().getName();
String name = targetClass.getName().asString();
DeclarationDescriptor parent = targetClass.getContainingDeclaration();
while (parent instanceof ClassDescriptor) {
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;
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() {
}
@@ -68,9 +68,9 @@ public final class DescriptorLookupConverter {
}
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 tailText = "";
boolean tailTextGrayed = true;

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