larc r19

55 lines ยท 2.0 KB Raw
1 package org.iwakura.larcjb
2
3 import com.intellij.openapi.options.Configurable
4 import com.intellij.openapi.project.Project
5 import com.intellij.openapi.vcs.AbstractVcs
6 import com.intellij.openapi.vcs.VcsKey
7 import com.intellij.openapi.vcs.changes.ChangeProvider
8 import com.intellij.openapi.vcs.checkin.CheckinEnvironment
9 import com.intellij.openapi.vcs.rollback.RollbackEnvironment
10 import com.intellij.openapi.vfs.VirtualFile
11 import org.iwakura.larcjb.changes.LarcChangeProvider
12 import org.iwakura.larcjb.checkin.LarcCheckinEnvironment
13 import org.iwakura.larcjb.rollback.LarcRollbackEnvironment
14
15 class LarcVcs(project: Project) : AbstractVcs(project, NAME) {
16
17 private val executable = LarcExecutable(project)
18 private val larcChangeProvider = LarcChangeProvider(project, executable)
19 private val larcCheckinEnvironment = LarcCheckinEnvironment(project, executable)
20 private val larcRollbackEnvironment = LarcRollbackEnvironment(project, executable)
21
22 override fun getDisplayName(): String = DISPLAY_NAME
23
24 override fun getChangeProvider(): ChangeProvider = larcChangeProvider
25
26 override fun getCheckinEnvironment(): CheckinEnvironment = larcCheckinEnvironment
27
28 override fun getRollbackEnvironment(): RollbackEnvironment = larcRollbackEnvironment
29
30 override fun getConfigurable(): Configurable = LarcVcsConfigurable(project)
31
32 override fun isVersionedDirectory(dir: VirtualFile): Boolean {
33 return dir.findChild(LARC_DIR) != null
34 }
35
36 fun getExecutable(): LarcExecutable = executable
37
38 /**
39 * Public accessor for VcsKey - delegates to AbstractVcs.getKeyInstanceMethod()
40 */
41 fun getVcsKey(): VcsKey = keyInstanceMethod
42
43 companion object {
44 const val NAME = "Larc"
45 const val DISPLAY_NAME = "Larc"
46 const val LARC_DIR = ".larc"
47
48 @JvmStatic
49 fun getInstance(project: Project): LarcVcs {
50 return project.getService(LarcVcs::class.java)
51 ?: throw IllegalStateException("LarcVcs service not found")
52 }
53 }
54 }
55