KotlinFileStubForIde: save full facadeFqName

Prefix is not necessarily same as packageFqName since JvmPackageName was introduced
This commit is contained in:
Pavel V. Talanov
2018-02-22 20:18:07 +01:00
parent 9e061555af
commit d2b90b84f8
3 changed files with 14 additions and 14 deletions
@@ -23,12 +23,12 @@ object KotlinStubVersions {
// Though only kotlin declarations (no code in the bodies) are stubbed, please do increase this version
// if you are not 100% sure it can be avoided.
// Increasing this version will lead to reindexing of all kotlin source files on the first IDE startup with the new version.
const val SOURCE_STUB_VERSION = 125
const val SOURCE_STUB_VERSION = 126
// Binary stub version should be increased if stub format (org.jetbrains.kotlin.psi.stubs.impl) is changed
// or changes are made to the core stub building code (org.jetbrains.kotlin.idea.decompiler.stubBuilder).
// Increasing this version will lead to reindexing of all binary files that are potentially kotlin binaries (including all class files).
private const val BINARY_STUB_VERSION = 63
private const val BINARY_STUB_VERSION = 64
// Classfile stub version should be increased if changes are made to classfile stub building subsystem (org.jetbrains.kotlin.idea.decompiler.classFile)
// Increasing this version will lead to reindexing of all classfiles.
@@ -261,9 +261,9 @@ public class IdeStubIndexService extends StubIndexService {
boolean isScript = file.isScriptByTree();
if (file.hasTopLevelCallables()) {
JvmFileClassInfo fileClassInfo = JvmFileClassUtil.getFileClassInfoNoResolve(file);
StringRef facadeSimpleName = StringRef.fromString(fileClassInfo.getFacadeClassFqName().shortName().asString());
StringRef facadeFqNameRef = StringRef.fromString(fileClassInfo.getFacadeClassFqName().asString());
StringRef partSimpleName = StringRef.fromString(fileClassInfo.getFileClassFqName().shortName().asString());
return new KotlinFileStubForIde(file, packageFqName, isScript, facadeSimpleName, partSimpleName, null);
return new KotlinFileStubForIde(file, packageFqName, isScript, facadeFqNameRef, partSimpleName, null);
}
return new KotlinFileStubForIde(file, packageFqName, isScript, null, null, null);
}
@@ -275,7 +275,8 @@ public class IdeStubIndexService extends StubIndexService {
KotlinFileStubForIde fileStub = (KotlinFileStubForIde) stub;
dataStream.writeName(fileStub.getPackageFqName().asString());
dataStream.writeBoolean(fileStub.isScript());
dataStream.writeName(StringRef.toString(fileStub.getFacadeSimpleName()));
FqName facadeFqName = fileStub.getFacadeFqName();
dataStream.writeName(facadeFqName != null ? facadeFqName.asString() : null);
dataStream.writeName(StringRef.toString(fileStub.getPartSimpleName()));
List<StringRef> facadePartNames = fileStub.getFacadePartSimpleNames();
if (facadePartNames == null) {
@@ -294,7 +295,7 @@ public class IdeStubIndexService extends StubIndexService {
public KotlinFileStub deserializeFileStub(@NotNull StubInputStream dataStream) throws IOException {
StringRef packageFqNameAsString = dataStream.readName();
boolean isScript = dataStream.readBoolean();
StringRef facadeSimpleName = dataStream.readName();
StringRef facadeStringRef = dataStream.readName();
StringRef partSimpleName = dataStream.readName();
int numPartNames = dataStream.readInt();
List<StringRef> facadePartNames = new ArrayList<StringRef>();
@@ -302,6 +303,6 @@ public class IdeStubIndexService extends StubIndexService {
StringRef partNameRef = dataStream.readName();
facadePartNames.add(partNameRef);
}
return new KotlinFileStubForIde(null, packageFqNameAsString, isScript, facadeSimpleName, partSimpleName, facadePartNames);
return new KotlinFileStubForIde(null, packageFqNameAsString, isScript, facadeStringRef, partSimpleName, facadePartNames);
}
}
@@ -28,18 +28,17 @@ class KotlinFileStubForIde(
jetFile: KtFile?,
packageName: StringRef,
isScript: Boolean,
val facadeSimpleName: StringRef?,
private val facadeFqNameRef: StringRef?,
val partSimpleName: StringRef?,
val facadePartSimpleNames: List<StringRef?>?
) : KotlinFileStubImpl(jetFile, packageName, isScript), KotlinFileStub, PsiClassHolderFileStub<KtFile> {
private fun StringRef.relativeToPackage() = getPackageFqName().child(Name.identifier(this.string))
val facadeFqName: FqName?
get() = facadeSimpleName?.relativeToPackage()
val partFqName: FqName?
get() = partSimpleName?.relativeToPackage()
val facadeFqName: FqName?
get() = facadeFqNameRef?.let { FqName(it.string) }
constructor(jetFile: KtFile?, packageName: String, isScript: Boolean)
: this(jetFile, StringRef.fromString(packageName)!!, isScript, null, null, null)
@@ -48,7 +47,7 @@ class KotlinFileStubForIde(
fun forFile(packageFqName: FqName, isScript: Boolean): KotlinFileStubImpl =
KotlinFileStubForIde(jetFile = null,
packageName = StringRef.fromString(packageFqName.asString())!!,
facadeSimpleName = null,
facadeFqNameRef = null,
partSimpleName = null,
facadePartSimpleNames = null,
isScript = isScript)
@@ -56,7 +55,7 @@ class KotlinFileStubForIde(
fun forFileFacadeStub(facadeFqName: FqName): KotlinFileStubImpl =
KotlinFileStubForIde(jetFile = null,
packageName = facadeFqName.parent().stringRef(),
facadeSimpleName = facadeFqName.shortName().stringRef(),
facadeFqNameRef = facadeFqName.stringRef(),
partSimpleName = facadeFqName.shortName().stringRef(),
facadePartSimpleNames = null,
isScript = false)
@@ -64,7 +63,7 @@ class KotlinFileStubForIde(
fun forMultifileClassStub(facadeFqName: FqName, partNames: List<String>?): KotlinFileStubImpl =
KotlinFileStubForIde(jetFile = null,
packageName = facadeFqName.parent().stringRef(),
facadeSimpleName = facadeFqName.shortName().stringRef(),
facadeFqNameRef = facadeFqName.stringRef(),
partSimpleName = null,
facadePartSimpleNames = partNames?.map { StringRef.fromString(it) },
isScript = false)