Skip to content

Commit 31e84ed

Browse files
committed
refactor: encapsulate all registry reading operations under CCRegistry
1 parent 216390f commit 31e84ed

4 files changed

Lines changed: 12 additions & 12 deletions

File tree

src/main/kotlin/com/github/lppedd/cc/CCRegistry.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,10 @@ internal object CCRegistry {
1818
else -> Locale.getDefault()
1919
}
2020
}
21+
22+
/**
23+
* Returns whether support for inspecting the VCS log is enabled.
24+
*/
25+
fun isVcsSupportEnabled(): Boolean =
26+
Registry.`is`(CC.Registry.VcsEnabled, false)
2127
}

src/main/kotlin/com/github/lppedd/cc/vcs/InternalRecentCommitsService.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
package com.github.lppedd.cc.vcs
22

3-
import com.github.lppedd.cc.CC
3+
import com.github.lppedd.cc.CCRegistry
44
import com.github.lppedd.cc.filterNotBlank
55
import com.github.lppedd.cc.parser.CCParser
66
import com.github.lppedd.cc.parser.FooterTokens
77
import com.github.lppedd.cc.parser.ValidToken
88
import com.github.lppedd.cc.trim
99
import com.intellij.openapi.components.service
1010
import com.intellij.openapi.project.Project
11-
import com.intellij.openapi.util.registry.Registry
1211
import com.intellij.openapi.vcs.VcsConfiguration
1312
import com.intellij.vcs.log.VcsCommitMetadata
1413
import kotlin.math.max
@@ -74,7 +73,7 @@ internal class InternalRecentCommitsService(private val project: Project) : Rece
7473
}
7574

7675
private fun getOrderedVcsCommitMessages(): Collection<String> {
77-
if (!Registry.`is`(CC.Registry.VcsEnabled, false)) {
76+
if (!CCRegistry.isVcsSupportEnabled()) {
7877
return emptyList()
7978
}
8079

src/main/kotlin/com/github/lppedd/cc/vcs/VcsCommitTokenProvider.kt

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,13 @@
11
package com.github.lppedd.cc.vcs
22

3-
import com.github.lppedd.cc.CC
3+
import com.github.lppedd.cc.*
44
import com.github.lppedd.cc.api.*
5-
import com.github.lppedd.cc.filterNotBlank
6-
import com.github.lppedd.cc.filterNotEmpty
75
import com.github.lppedd.cc.parser.CCParser
86
import com.github.lppedd.cc.parser.CommitTokens
97
import com.github.lppedd.cc.parser.FooterTokens
108
import com.github.lppedd.cc.parser.ValidToken
11-
import com.github.lppedd.cc.trim
129
import com.intellij.openapi.components.service
1310
import com.intellij.openapi.project.Project
14-
import com.intellij.openapi.util.registry.Registry
1511
import javax.swing.Icon
1612
import kotlin.text.RegexOption.MULTILINE
1713

@@ -129,7 +125,7 @@ internal class VcsCommitTokenProvider(project: Project)
129125
.filterNotEmpty()
130126

131127
private fun getOrderedVcsCommitMessages(): Sequence<String> {
132-
if (!Registry.`is`(CC.Registry.VcsEnabled, false)) {
128+
if (!CCRegistry.isVcsSupportEnabled()) {
133129
return emptySequence()
134130
}
135131

src/main/kotlin/com/github/lppedd/cc/vcs/VcsStartupActivity.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
package com.github.lppedd.cc.vcs
22

3-
import com.github.lppedd.cc.CC
3+
import com.github.lppedd.cc.CCRegistry
44
import com.intellij.openapi.application.ApplicationManager
55
import com.intellij.openapi.components.service
66
import com.intellij.openapi.project.DumbAware
77
import com.intellij.openapi.project.Project
88
import com.intellij.openapi.startup.ProjectActivity
9-
import com.intellij.openapi.util.registry.Registry
109
import com.intellij.openapi.vcs.ProjectLevelVcsManager
1110
import com.intellij.openapi.vcs.VcsListener
1211

@@ -16,7 +15,7 @@ import com.intellij.openapi.vcs.VcsListener
1615
internal class VcsStartupActivity : ProjectActivity, DumbAware {
1716
override suspend fun execute(project: Project) {
1817
val vcsConfigListener = VcsListener {
19-
if (Registry.`is`(CC.Registry.VcsEnabled, false)) {
18+
if (CCRegistry.isVcsSupportEnabled()) {
2019
ApplicationManager.getApplication().executeOnPooledThread {
2120
val vcsHandler = project.service<VcsService>()
2221
vcsHandler.refresh()

0 commit comments

Comments
 (0)