Drop package facades:

- getting rid of package facades in InlineCodegen & related stuff.
Provide binary source element to top-level package members.
This commit is contained in:
Dmitry Petrov
2015-10-16 21:52:11 +03:00
parent 989f761166
commit 70c91b2e75
10 changed files with 127 additions and 71 deletions
@@ -20,6 +20,7 @@ import com.google.protobuf.MessageLite
import com.intellij.psi.util.CachedValueProvider
import com.intellij.psi.util.CachedValuesManager
import org.jetbrains.kotlin.descriptors.PackageFragmentDescriptor
import org.jetbrains.kotlin.load.java.descriptors.getImplClassName
import org.jetbrains.kotlin.load.kotlin.PackageClassUtils
import org.jetbrains.kotlin.load.kotlin.PackagePartClassUtils
import org.jetbrains.kotlin.name.FqName
@@ -70,24 +71,11 @@ public object JvmFileClassUtil {
@JvmStatic
public fun getImplClassName(callable: DeserializedCallableMemberDescriptor): Name? =
getImplClassName(callable.proto, callable.nameResolver)
callable.getImplClassName()
@JvmStatic
public fun getImplClassName(proto: MessageLite, nameResolver: NameResolver): Name? =
when (proto) {
is ProtoBuf.Constructor ->
null
is ProtoBuf.Function ->
if (proto.hasExtension(JvmProtoBuf.methodImplClassName))
proto.getExtension(JvmProtoBuf.methodImplClassName)
else null
is ProtoBuf.Property ->
if (proto.hasExtension(JvmProtoBuf.propertyImplClassName))
proto.getExtension(JvmProtoBuf.propertyImplClassName)
else null
else ->
error("Unknown message: $proto")
}?.let { nameResolver.getName(it) }
getImplClassName(proto, nameResolver)
@JvmStatic
public fun getHiddenPartFqName(file: JetFile, jvmFileClassAnnotations: ParsedJmvFileClassAnnotations): FqName =
@@ -46,14 +46,21 @@ public fun isContainedByCompiledPartOfOurModule(descriptor: DeclarationDescripto
if (outDirectory == null || packageFragment !is LazyJavaPackageFragment) return false
val source = getSourceElement(descriptor)
if (source is KotlinJvmBinarySourceElement) {
val binaryClass = source.binaryClass
if (binaryClass is VirtualFileKotlinClass) {
val file = binaryClass.file
if (file.fileSystem.protocol == StandardFileSystems.FILE_PROTOCOL) {
val ioFile = VfsUtilCore.virtualToIoFile(file)
return ioFile.absolutePath.startsWith(outDirectory.absolutePath + File.separator);
}
val binaryClass = when (source) {
is KotlinJvmBinarySourceElement ->
source.binaryClass
is KotlinJvmBinaryPackageSourceElement ->
source.getRepresentativeBinaryClass()
else ->
null
}
if (binaryClass is VirtualFileKotlinClass) {
val file = binaryClass.file
if (file.fileSystem.protocol == StandardFileSystems.FILE_PROTOCOL) {
val ioFile = VfsUtilCore.virtualToIoFile(file)
return ioFile.absolutePath.startsWith(outDirectory.absolutePath + File.separator);
}
}