
org.jacodb.impl.LocationsRegistry.kt Maven / Gradle / Ivy
Show all versions of jacodb-core Show documentation
/*
* Copyright 2022 UnitTestBot contributors (utbot.org)
*
* 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.jacodb.impl
import org.jacodb.api.JcByteCodeLocation
import org.jacodb.api.RegisteredLocation
import java.io.Closeable
interface LocationsRegistry : Closeable {
// all locations
val actualLocations: List
val runtimeLocations: List
fun cleanup(): CleanupResult
fun refresh(): RefreshResult
fun setup(runtimeLocations: List): RegistrationResult
fun registerIfNeeded(locations: List): RegistrationResult
fun afterProcessing(locations: List)
fun newSnapshot(classpathSetLocations: List): LocationsRegistrySnapshot
fun close(snapshot: LocationsRegistrySnapshot)
fun RegisteredLocation.hasReferences(snapshots: Set): Boolean {
return snapshots.isNotEmpty() && snapshots.any { it.ids.contains(id) }
}
}
class RegistrationResult(val registered: List, val new: List)
class RefreshResult(val new: List)
class CleanupResult(val outdated: List)
open class LocationsRegistrySnapshot(
private val registry: LocationsRegistry,
val locations: List
) : Closeable {
val ids = locations.map { it.id }.toHashSet()
override fun close() = registry.close(this)
}