Fix incremental packages
This commit is contained in:
+25
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* Copyright 2010-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.load.kotlin.incremental
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.SourceElement
|
||||
import java.io.File
|
||||
|
||||
public class FileSourceElement(private val file: File) : SourceElement {
|
||||
public val path: String
|
||||
get() = file.canonicalPath
|
||||
}
|
||||
+12
@@ -21,8 +21,10 @@ import org.apache.log4j.Logger
|
||||
import org.jetbrains.kotlin.descriptors.ModuleDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.PackageFragmentDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.PackageFragmentProvider
|
||||
import org.jetbrains.kotlin.descriptors.SourceElement
|
||||
import org.jetbrains.kotlin.descriptors.impl.PackageFragmentDescriptorImpl
|
||||
import org.jetbrains.kotlin.load.kotlin.ModuleMapping
|
||||
import org.jetbrains.kotlin.load.kotlin.PackageClassUtils
|
||||
import org.jetbrains.kotlin.load.kotlin.PackagePartClassUtils
|
||||
import org.jetbrains.kotlin.load.kotlin.incremental.components.IncrementalCache
|
||||
import org.jetbrains.kotlin.modules.Module
|
||||
@@ -42,6 +44,7 @@ import org.jetbrains.kotlin.serialization.jvm.JvmProtoBufUtil
|
||||
import org.jetbrains.kotlin.storage.NotNullLazyValue
|
||||
import org.jetbrains.kotlin.storage.StorageManager
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.singletonOrEmptyList
|
||||
import java.io.File
|
||||
import java.util.*
|
||||
|
||||
public class IncrementalPackageFragmentProvider(
|
||||
@@ -97,6 +100,13 @@ public class IncrementalPackageFragmentProvider(
|
||||
public val target: Module
|
||||
get() = this@IncrementalPackageFragmentProvider.target
|
||||
|
||||
private val sourceElement: SourceElement by lazy {
|
||||
val incrementalCache = this@IncrementalPackageFragmentProvider.incrementalCache
|
||||
val packageClassName = PackageClassUtils.getPackageClassName(fqName)
|
||||
val classFilePath = incrementalCache.getClassFilePath(packageClassName)
|
||||
FileSourceElement(File(classFilePath))
|
||||
}
|
||||
|
||||
val memberScope: NotNullLazyValue<JetScope> = storageManager.createLazyValue {
|
||||
if (fqName !in fqNamesToLoad) {
|
||||
JetScope.Empty
|
||||
@@ -136,6 +146,8 @@ public class IncrementalPackageFragmentProvider(
|
||||
}
|
||||
}
|
||||
|
||||
override fun getSource(): SourceElement = sourceElement
|
||||
|
||||
override fun getMemberScope(): JetScope = memberScope()
|
||||
|
||||
private inner class IncrementalPackageScope(val packageData: PackageData) : DeserializedPackageMemberScope(
|
||||
|
||||
+2
@@ -25,5 +25,7 @@ public interface IncrementalCache {
|
||||
|
||||
public fun getModuleMappingData(): ByteArray?
|
||||
|
||||
public fun getClassFilePath(internalClassName: String): String
|
||||
|
||||
public fun close()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user