Rename JvmClassName.getFqName() and add a warning

All usages of this method as of right now seem wrong, as they don't work in the
case of classes which contain dollars in their names -- dollars get replaced to
dots
This commit is contained in:
Alexander Udalov
2013-10-03 19:56:43 +04:00
parent e8d4aae48b
commit dbba6c614b
6 changed files with 11 additions and 6 deletions
@@ -69,7 +69,8 @@ public class KotlinLightClassForExplicitDeclaration extends AbstractLightClass i
String jvmInternalName = PsiCodegenPredictor.getPredefinedJvmInternalName(classOrObject);
if (jvmInternalName == null) return null;
return new KotlinLightClassForExplicitDeclaration(manager, JvmClassName.byInternalName(jvmInternalName).getFqName(), classOrObject);
FqName fqName = JvmClassName.byInternalName(jvmInternalName).getFqNameForClassNameWithoutDollars();
return new KotlinLightClassForExplicitDeclaration(manager, fqName, classOrObject);
}
private final FqName classFqName; // FqName of (possibly inner) class
@@ -77,8 +77,11 @@ public class JvmClassName {
this.internalName = internalName;
}
/**
* WARNING: internal name cannot be converted to FQ name for a class which contains dollars in the name
*/
@NotNull
public FqName getFqName() {
public FqName getFqNameForClassNameWithoutDollars() {
if (fqName == null) {
fqName = new FqName(internalNameToFqName(internalName));
}
@@ -210,7 +210,8 @@ public class AnnotationDescriptorDeserializer implements AnnotationDeserializer
@NotNull
private ClassDescriptor resolveClass(@NotNull JvmClassName className) {
ClassDescriptor annotationClass = javaClassResolver.resolveClass(className.getFqName(), IGNORE_KOTLIN_SOURCES);
ClassDescriptor annotationClass = javaClassResolver.resolveClass(className.getFqNameForClassNameWithoutDollars(),
IGNORE_KOTLIN_SOURCES);
return annotationClass != null ? annotationClass : ErrorUtils.getErrorClass();
}
@@ -66,7 +66,7 @@ public final class DecompiledDataFactory {
this.javaDescriptorResolver = injector.getJavaDescriptorResolver();
VirtualFileKotlinClass kotlinClass = new VirtualFileKotlinClass(classFile);
this.classFqName = kotlinClass.getClassName().getFqName();
this.classFqName = kotlinClass.getClassName().getFqNameForClassNameWithoutDollars();
KotlinClassFileHeader header = KotlinClassFileHeader.readKotlinHeaderFromClassFile(kotlinClass);
assert header instanceof SerializedDataHeader : "Decompiled data factory shouldn't be called on an unsupported file: " + classFile;
@@ -370,7 +370,7 @@ public class JetSourceNavigationHelper {
if (internalName == null) {
return null;
}
String fqName = JvmClassName.byInternalName(internalName).getFqName().asString();
String fqName = JvmClassName.byInternalName(internalName).getFqNameForClassNameWithoutDollars().asString();
JetFile file = (JetFile) classOrObject.getContainingFile();
@@ -78,7 +78,7 @@ public final class KotlinClassFileIndex extends ScalarIndexExtension<FqName> {
VirtualFileKotlinClass kotlinClass = new VirtualFileKotlinClass(inputData.getFile());
KotlinClassFileHeader header = KotlinClassFileHeader.readKotlinHeaderFromClassFile(kotlinClass);
if (header != null && !(header instanceof IncompatibleAnnotationHeader)) {
return Collections.singletonMap(kotlinClass.getClassName().getFqName(), null);
return Collections.singletonMap(kotlinClass.getClassName().getFqNameForClassNameWithoutDollars(), null);
}
}
catch (Throwable e) {