Make Kotlin OOCBM updater for modules internal again
Replace direct API access with dedicated service.
This commit is contained in:
+5
-4
@@ -7,14 +7,15 @@ package org.jetbrains.kotlin.idea.caches.project
|
|||||||
|
|
||||||
import com.intellij.openapi.util.ModificationTracker
|
import com.intellij.openapi.util.ModificationTracker
|
||||||
import org.jetbrains.kotlin.idea.caches.resolve.ResolutionAnchorCacheService
|
import org.jetbrains.kotlin.idea.caches.resolve.ResolutionAnchorCacheService
|
||||||
import org.jetbrains.kotlin.idea.caches.trackers.KotlinCodeBlockModificationListener
|
import org.jetbrains.kotlin.idea.caches.trackers.ResolutionAnchorModificationCountService
|
||||||
|
|
||||||
class ResolutionAnchorAwareLibraryModificationTracker(
|
class ResolutionAnchorAwareLibraryModificationTracker(
|
||||||
private val libraryInfo: LibraryInfo,
|
private val libraryInfo: LibraryInfo,
|
||||||
) : ModificationTracker {
|
) : ModificationTracker {
|
||||||
override fun getModificationCount(): Long {
|
override fun getModificationCount(): Long {
|
||||||
val anchorDependencies = ResolutionAnchorCacheService.getInstance(libraryInfo.project).getDependencyResolutionAnchors(libraryInfo)
|
val anchorDependencyModules = ResolutionAnchorCacheService.getInstance(libraryInfo.project)
|
||||||
val updaterForModules = KotlinCodeBlockModificationListener.getInstance(libraryInfo.project).perModuleOutOfCodeBlockTrackerUpdater
|
.getDependencyResolutionAnchors(libraryInfo)
|
||||||
return anchorDependencies.maxOfOrNull { updaterForModules.getModificationCount(it.module) } ?: 0
|
.map { it.module }
|
||||||
|
return ResolutionAnchorModificationCountService.getLatestModificationCount(anchorDependencyModules)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-2
@@ -50,8 +50,7 @@ abstract class KotlinCodeBlockModificationListenerCompat(protected val project:
|
|||||||
|
|
||||||
lateinit var kotlinOutOfCodeBlockTracker: ModificationTracker
|
lateinit var kotlinOutOfCodeBlockTracker: ModificationTracker
|
||||||
|
|
||||||
// TODO: close back exposed API
|
internal val perModuleOutOfCodeBlockTrackerUpdater = KotlinModuleOutOfCodeBlockModificationTracker.Updater(project)
|
||||||
val perModuleOutOfCodeBlockTrackerUpdater = KotlinModuleOutOfCodeBlockModificationTracker.Updater(project)
|
|
||||||
|
|
||||||
protected fun init(
|
protected fun init(
|
||||||
treeAspect: TreeAspect,
|
treeAspect: TreeAspect,
|
||||||
|
|||||||
+2
-4
@@ -68,8 +68,7 @@ class KotlinModuleOutOfCodeBlockModificationTracker private constructor(private
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: close back exposed API
|
internal class Updater(project: Project) {
|
||||||
class Updater(project: Project) {
|
|
||||||
private val kotlinOfOfCodeBlockTracker by lazy {
|
private val kotlinOfOfCodeBlockTracker by lazy {
|
||||||
KotlinCodeBlockModificationListener.getInstance(project).kotlinOutOfCodeBlockTracker
|
KotlinCodeBlockModificationListener.getInstance(project).kotlinOutOfCodeBlockTracker
|
||||||
}
|
}
|
||||||
@@ -84,8 +83,7 @@ class KotlinModuleOutOfCodeBlockModificationTracker private constructor(private
|
|||||||
// perModuleModCount map
|
// perModuleModCount map
|
||||||
private var perModuleChangesHighWatermark: Long? = null
|
private var perModuleChangesHighWatermark: Long? = null
|
||||||
|
|
||||||
// TODO: close back exposed API
|
internal fun getModificationCount(module: Module): Long {
|
||||||
fun getModificationCount(module: Module): Long {
|
|
||||||
return perModuleModCount[module] ?: perModuleChangesHighWatermark ?: kotlinOfOfCodeBlockTracker.modificationCount
|
return perModuleModCount[module] ?: perModuleChangesHighWatermark ?: kotlinOfOfCodeBlockTracker.modificationCount
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+21
@@ -0,0 +1,21 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||||
|
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.jetbrains.kotlin.idea.caches.trackers
|
||||||
|
|
||||||
|
import com.intellij.openapi.module.Module
|
||||||
|
import com.intellij.openapi.util.ModificationTracker
|
||||||
|
|
||||||
|
object ResolutionAnchorModificationCountService {
|
||||||
|
fun getLatestModificationCount(anchorModules: Collection<Module>): Long {
|
||||||
|
if (anchorModules.isEmpty())
|
||||||
|
return ModificationTracker.NEVER_CHANGED.modificationCount
|
||||||
|
|
||||||
|
val modificationCountUpdater =
|
||||||
|
KotlinCodeBlockModificationListener.getInstance(anchorModules.first().project).perModuleOutOfCodeBlockTrackerUpdater
|
||||||
|
return anchorModules.maxOfOrNull { modificationCountUpdater.getModificationCount(it) }
|
||||||
|
?: ModificationTracker.NEVER_CHANGED.modificationCount
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user