Skip to content

Commit 78d0bf5

Browse files
committed
chore(bulk-model-sync): fix detekt warnings
1 parent a57d64d commit 78d0bf5

File tree

5 files changed

+16
-12
lines changed

5 files changed

+16
-12
lines changed

bulk-model-sync-lib/src/jvmMain/kotlin/org/modelix/model/sync/bulk/InvalidatingVisitor.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ import org.modelix.model.api.ITree
2020
import org.modelix.model.api.ITreeChangeVisitorEx
2121
import org.modelix.model.data.NodeData
2222

23+
/**
24+
* Visitor that visits a [tree] and stores the invalidation information in an [invalidationTree].
25+
*/
2326
class InvalidatingVisitor(val tree: ITree, val invalidationTree: InvalidationTree) : ITreeChangeVisitorEx {
2427

2528
private fun invalidateNode(nodeId: Long) = invalidationTree.invalidate(tree, nodeId)

bulk-model-sync-lib/src/jvmTest/kotlin/org/modelix/model/sync/bulk/ModelSynchronizerWithInvalidationTreeTest.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,12 @@ class ModelSynchronizerWithInvalidationTreeTest : AbstractModelSyncTest() {
7474
val rootNode = sourceBranch.getRootNode()
7575
rootNode.setPropertyValue(IProperty.fromName(ID_PROPERTY_KEY), rootNode.reference.serialize())
7676
val grower = RandomModelChangeGenerator(rootNode, rand).growingOperationsOnly()
77-
for (i in 1..100) {
77+
repeat(100) {
7878
grower.applyRandomChange()
7979
}
8080

8181
val changer = RandomModelChangeGenerator(rootNode, rand)
82-
for (i in 1..numChanges) {
82+
repeat(numChanges) {
8383
changer.applyRandomChange()
8484
}
8585
}

bulk-model-sync-mps/src/main/kotlin/org/modelix/mps/model/sync/bulk/IncludedModulesFilter.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ import org.modelix.model.api.INode
2121
import org.modelix.model.sync.bulk.ModelSynchronizer
2222

2323
/**
24-
* A filter that skips nodes, which represent MPS modules and do not match the included module names or prefixes.
24+
* A filter that skips nodes, which represent MPS modules and do not match
25+
* the included module names ([includedModules]) or prefixes ([includedModulePrefixes]).
2526
*
2627
* Note: This is currently not meant to be used standalone.
2728
* It should be used with other filters in a [CompositeFilter].

bulk-model-sync-mps/src/main/kotlin/org/modelix/mps/model/sync/bulk/MPSBulkSynchronizer.kt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,10 @@ object MPSBulkSynchronizer {
205205
}
206206
}
207207

208+
/**
209+
* Import from model-server via [INode]-based [ModelSynchronizer].
210+
* Requires a specified baseVersion.
211+
*/
208212
@JvmStatic
209213
fun importRepositoryFromModelServer() {
210214
val repository = getRepository()
@@ -220,22 +224,18 @@ object MPSBulkSynchronizer {
220224
val branchName = System.getProperty("modelix.mps.model.sync.bulk.server.branch")
221225
val branchRef = repositoryId.getBranchReference(branchName)
222226
val versionHash: String? = System.getProperty("modelix.mps.model.sync.bulk.server.version.hash")
223-
val baseVersionHash: String? = System.getProperty("modelix.mps.model.sync.bulk.server.version.base.hash")
227+
val baseVersionHash = requireNotNull(System.getProperty("modelix.mps.model.sync.bulk.server.version.base.hash")) { "modelix.mps.model.sync.bulk.server.version.base.hash not specified" }
224228
val client = ModelClientV2.builder().url(modelServerUrl).build()
225229
val version = runBlocking {
226230
if (versionHash == null) client.lazyLoadVersion(branchRef) else client.lazyLoadVersion(repositoryId, versionHash)
227231
}
228-
val baseVersion = baseVersionHash?.let {
229-
runBlocking {
230-
client.lazyLoadVersion(repositoryId, it)
231-
}
232+
val baseVersion = runBlocking {
233+
client.lazyLoadVersion(repositoryId, baseVersionHash)
232234
}
233235
println("Loading version ${version.getContentHash()}")
234236

235237
val access = repository.modelAccess
236238
access.executeCommandInEDT {
237-
if (baseVersion == null) return@executeCommandInEDT
238-
239239
val invalidationTree = InvalidationTree(1_000_000)
240240
val newTree = version.getTree()
241241
newTree.visitChanges(

bulk-model-sync-mps/src/main/kotlin/org/modelix/mps/model/sync/bulk/NodeAssociations.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import org.modelix.model.data.NodeData
2828
import org.modelix.model.mpsadapters.MPSArea
2929
import org.modelix.model.sync.bulk.INodeAssociation
3030

31-
class NodeAssociationToModelServer(val branch: IBranch) : INodeAssociation {
31+
internal class NodeAssociationToModelServer(val branch: IBranch) : INodeAssociation {
3232

3333
private val modelIndex
3434
get() = ModelIndex.get(branch.transaction, NodeData.ID_PROPERTY_KEY)
@@ -42,7 +42,7 @@ class NodeAssociationToModelServer(val branch: IBranch) : INodeAssociation {
4242
}
4343
}
4444

45-
class NodeAssociationToMps(val mpsArea: MPSArea) : INodeAssociation {
45+
internal class NodeAssociationToMps(val mpsArea: MPSArea) : INodeAssociation {
4646

4747
private val serverToMps: TLongObjectMap<INode> = TLongObjectHashMap()
4848

0 commit comments

Comments
 (0)