-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathIModelSyncService.kt
70 lines (57 loc) · 2 KB
/
IModelSyncService.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
package org.modelix.mps.sync3
import com.intellij.openapi.components.service
import jetbrains.mps.ide.project.ProjectHelper
import kotlinx.coroutines.runBlocking
import org.modelix.model.IVersion
import org.modelix.model.client2.IModelClientV2
import org.modelix.model.lazy.BranchReference
import java.io.Closeable
interface IModelSyncService {
companion object {
@JvmStatic
fun getInstance(project: com.intellij.openapi.project.Project): IModelSyncService {
return project.service<ModelSyncService>()
}
@JvmStatic
fun getInstance(project: org.jetbrains.mps.openapi.project.Project): IModelSyncService {
return getInstance(ProjectHelper.toIdeaProject(project as jetbrains.mps.project.Project))
}
}
fun addServer(url: String): IServerConnection
fun getServerConnections(): List<IServerConnection>
fun getBindings(): List<IBinding>
}
interface IServerConnection : Closeable {
fun activate()
fun deactivate()
fun remove()
fun getStatus(): Status
override fun close() = deactivate()
suspend fun pullVersion(branchRef: BranchReference): IVersion
fun bind(branchRef: BranchReference): IBinding = bind(branchRef, null)
fun bind(branchRef: BranchReference, lastSyncedVersionHash: String?): IBinding
fun getBindings(): List<IBinding>
fun getUrl(): String
suspend fun getClient(): IModelClientV2
enum class Status {
CONNECTED,
DISCONNECTED,
}
}
interface IBinding : Closeable {
fun getProject(): org.jetbrains.mps.openapi.project.Project
fun getBranchRef(): BranchReference
fun isEnabled(): Boolean
fun enable()
fun disable()
fun delete()
override fun close() = disable()
/**
* Blocks until both ends are in sync.
* @exception Throwable if the last synchronization failed
* @return the latest version
*/
suspend fun flush(): IVersion
fun flushBlocking() = runBlocking { flush() }
suspend fun flushIfEnabled(): IVersion?
}