Simplified interface of IncrementalCache (depending on JDK only).
This commit is contained in:
+3
-1
@@ -52,6 +52,7 @@ import org.jetbrains.jet.lang.resolve.ScriptNameUtil;
|
|||||||
import org.jetbrains.jet.lang.resolve.java.AnalyzerFacadeForJVM;
|
import org.jetbrains.jet.lang.resolve.java.AnalyzerFacadeForJVM;
|
||||||
import org.jetbrains.jet.lang.resolve.java.PackageClassUtils;
|
import org.jetbrains.jet.lang.resolve.java.PackageClassUtils;
|
||||||
import org.jetbrains.jet.lang.resolve.kotlin.incremental.IncrementalCacheProvider;
|
import org.jetbrains.jet.lang.resolve.kotlin.incremental.IncrementalCacheProvider;
|
||||||
|
import org.jetbrains.jet.lang.resolve.kotlin.incremental.IncrementalPackage;
|
||||||
import org.jetbrains.jet.lang.resolve.name.FqName;
|
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||||
import org.jetbrains.jet.plugin.MainFunctionDetector;
|
import org.jetbrains.jet.plugin.MainFunctionDetector;
|
||||||
import org.jetbrains.jet.utils.KotlinPaths;
|
import org.jetbrains.jet.utils.KotlinPaths;
|
||||||
@@ -332,7 +333,8 @@ public class KotlinToJVMBytecodeCompiler {
|
|||||||
Collection<FqName> packagesWithRemovedFiles =
|
Collection<FqName> packagesWithRemovedFiles =
|
||||||
incrementalCacheDir == null || moduleId == null || incrementalCacheProvider == null
|
incrementalCacheDir == null || moduleId == null || incrementalCacheProvider == null
|
||||||
? null
|
? null
|
||||||
: incrementalCacheProvider.getIncrementalCache(incrementalCacheDir).getPackagesWithRemovedFiles(moduleId, environment.getSourceFiles());
|
: IncrementalPackage.getPackagesWithRemovedFiles(
|
||||||
|
incrementalCacheProvider.getIncrementalCache(incrementalCacheDir), moduleId, environment.getSourceFiles());
|
||||||
GenerationState generationState = new GenerationState(
|
GenerationState generationState = new GenerationState(
|
||||||
environment.getProject(), ClassBuilderFactories.BINARIES, Progress.DEAF,
|
environment.getProject(), ClassBuilderFactories.BINARIES, Progress.DEAF,
|
||||||
exhaust.getModuleDescriptor(), exhaust.getBindingContext(), sourceFiles,
|
exhaust.getModuleDescriptor(), exhaust.getBindingContext(), sourceFiles,
|
||||||
|
|||||||
+21
-4
@@ -19,11 +19,28 @@ package org.jetbrains.jet.lang.resolve.kotlin.incremental
|
|||||||
import org.jetbrains.jet.lang.resolve.name.FqName
|
import org.jetbrains.jet.lang.resolve.name.FqName
|
||||||
import org.jetbrains.jet.lang.resolve.java.JvmClassName
|
import org.jetbrains.jet.lang.resolve.java.JvmClassName
|
||||||
import org.jetbrains.jet.lang.psi.JetFile
|
import org.jetbrains.jet.lang.psi.JetFile
|
||||||
|
import java.util.HashMap
|
||||||
|
import java.io.File
|
||||||
|
|
||||||
public trait IncrementalCache {
|
public trait IncrementalCache {
|
||||||
public fun getPackagesWithRemovedFiles(moduleId: String, compiledSourceFiles: Collection<JetFile>): Collection<FqName>
|
public fun getRemovedPackageParts(moduleId: String, compiledSourceFilesToFqName: Map<File, String>): Collection<String>
|
||||||
|
|
||||||
public fun getRemovedPackageParts(moduleId: String, compiledSourceFiles: Collection<JetFile>): Collection<JvmClassName>
|
public fun getPackageData(moduleId: String, fqName: String): ByteArray?
|
||||||
|
}
|
||||||
public fun getPackageData(moduleId: String, fqName: FqName): ByteArray?
|
|
||||||
|
public fun IncrementalCache.getPackagesWithRemovedFiles(moduleId: String, compiledSourceFiles: Collection<JetFile>): Collection<FqName> {
|
||||||
|
return getRemovedPackageParts(moduleId, compiledSourceFiles).map { it.getFqNameForClassNameWithoutDollars().parent() }
|
||||||
|
}
|
||||||
|
|
||||||
|
public fun IncrementalCache.getRemovedPackageParts(moduleId: String, compiledSourceFiles: Collection<JetFile>): Collection<JvmClassName> {
|
||||||
|
val compiledSourceFilesToFqName = HashMap<File, String>()
|
||||||
|
for (sourceFile in compiledSourceFiles) {
|
||||||
|
compiledSourceFilesToFqName[File(sourceFile.getVirtualFile()!!.getPath())] = sourceFile.getPackageFqName().asString()
|
||||||
|
}
|
||||||
|
|
||||||
|
return getRemovedPackageParts(moduleId, compiledSourceFilesToFqName).map { JvmClassName.byInternalName(it) }
|
||||||
|
}
|
||||||
|
|
||||||
|
public fun IncrementalCache.getPackageData(moduleId: String, fqName: FqName): ByteArray? {
|
||||||
|
return getPackageData(moduleId, fqName.asString())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -168,31 +168,22 @@ public class IncrementalCacheImpl(baseDir: File): IncrementalCache {
|
|||||||
putPackagePartSourceData(moduleId, sourceFile, null)
|
putPackagePartSourceData(moduleId, sourceFile, null)
|
||||||
}
|
}
|
||||||
|
|
||||||
public override fun getPackagesWithRemovedFiles(moduleId: String, compiledSourceFiles: Collection<JetFile>): Collection<FqName> {
|
public override fun getRemovedPackageParts(moduleId: String, compiledSourceFilesToFqName: Map<File, String>): Collection<String> {
|
||||||
return getRemovedPackageParts(moduleId, compiledSourceFiles).map { it.getFqNameForClassNameWithoutDollars().parent() }
|
val result = HashSet<String>()
|
||||||
}
|
|
||||||
|
|
||||||
public override fun getRemovedPackageParts(moduleId: String, compiledSourceFiles: Collection<JetFile>): Collection<JvmClassName> {
|
|
||||||
val sourceFileToCurrentFqNameMap = HashMap<File, FqName>()
|
|
||||||
for (sourceFile in compiledSourceFiles) {
|
|
||||||
sourceFileToCurrentFqNameMap[File(sourceFile.getVirtualFile()!!.getPath())] = sourceFile.getPackageFqName()
|
|
||||||
}
|
|
||||||
|
|
||||||
val result = HashSet<JvmClassName>()
|
|
||||||
|
|
||||||
packageSourcesData.processKeysWithExistingMapping { key ->
|
packageSourcesData.processKeysWithExistingMapping { key ->
|
||||||
if (key!!.startsWith(moduleId + File.pathSeparator)) {
|
if (key!!.startsWith(moduleId + File.pathSeparator)) {
|
||||||
val indexOf = key.indexOf(File.pathSeparator)
|
val indexOf = key.indexOf(File.pathSeparator)
|
||||||
val sourceFile = File(key.substring(indexOf + 1))
|
val sourceFile = File(key.substring(indexOf + 1))
|
||||||
|
|
||||||
val packagePartClassName = JvmClassName.byInternalName(packageSourcesData[key]!!)
|
val packagePartClassName = packageSourcesData[key]!!
|
||||||
if (!sourceFile.exists()) {
|
if (!sourceFile.exists()) {
|
||||||
result.add(packagePartClassName)
|
result.add(packagePartClassName)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
val previousPackageFqName = packagePartClassName.getFqNameForClassNameWithoutDollars().parent()
|
val previousPackageFqName = JvmClassName.byInternalName(packagePartClassName).getFqNameForClassNameWithoutDollars().parent()
|
||||||
val currentPackageFqName = sourceFileToCurrentFqNameMap[sourceFile]
|
val currentPackageFqName = compiledSourceFilesToFqName[sourceFile]
|
||||||
if (currentPackageFqName != null && currentPackageFqName != previousPackageFqName) {
|
if (currentPackageFqName != null && currentPackageFqName != previousPackageFqName.asString()) {
|
||||||
result.add(packagePartClassName)
|
result.add(packagePartClassName)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -204,8 +195,8 @@ public class IncrementalCacheImpl(baseDir: File): IncrementalCache {
|
|||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
public override fun getPackageData(moduleId: String, fqName: FqName): ByteArray? {
|
public override fun getPackageData(moduleId: String, fqName: String): ByteArray? {
|
||||||
return protoData[ClassOrPackageId(moduleId, fqName)]
|
return protoData[ClassOrPackageId(moduleId, FqName(fqName))]
|
||||||
}
|
}
|
||||||
|
|
||||||
public fun close() {
|
public fun close() {
|
||||||
|
|||||||
Reference in New Issue
Block a user