File tree Expand file tree Collapse file tree 4 files changed +22
-18
lines changed
src/main/kotlin/com/github/blarc/gitlab/template/lint/plugin Expand file tree Collapse file tree 4 files changed +22
-18
lines changed Original file line number Diff line number Diff line change @@ -8,7 +8,6 @@ import com.intellij.ui.EditorNotifications
88import kotlinx.coroutines.CoroutineScope
99import kotlinx.coroutines.Dispatchers
1010import kotlinx.coroutines.launch
11- import kotlinx.coroutines.withContext
1211
1312
1413fun lintGitlabYaml (file : PsiFile ) {
@@ -21,13 +20,10 @@ fun lint(file: PsiFile) {
2120 val project = file.project
2221 val pipeline = project.service<Pipeline >()
2322
24- CoroutineScope (Dispatchers .IO ).launch {
23+ CoroutineScope (Dispatchers .Default ).launch {
2524 withBackgroundProgress(file.project, GitlabLintBundle .message(" inspection.title" )) {
2625 pipeline.accept(file)
27-
28- withContext(Dispatchers .Main ) {
29- EditorNotifications .getInstance(project).updateAllNotifications()
30- }
26+ EditorNotifications .getInstance(project).updateAllNotifications()
3127 }
3228 }
3329}
Original file line number Diff line number Diff line change @@ -20,4 +20,4 @@ class SaveActionListener(val project: Project) : FileDocumentManagerListener {
2020 super .beforeDocumentSaving(document)
2121 }
2222 }
23- }
23+ }
Original file line number Diff line number Diff line change @@ -12,6 +12,8 @@ import com.intellij.openapi.command.WriteCommandAction
1212import com.intellij.openapi.components.Service
1313import com.intellij.openapi.components.service
1414import com.intellij.openapi.fileEditor.FileEditorManager
15+ import kotlinx.coroutines.Dispatchers
16+ import kotlinx.coroutines.withContext
1517
1618@Service(Service .Level .PROJECT )
1719class LintContext : Middleware {
@@ -78,7 +80,7 @@ class LintContext : Middleware {
7880 }
7981 }
8082
81- private fun lintContent (
83+ private suspend fun lintContent (
8284 gitlab : Gitlab ,
8385 gitlabUrl : String ,
8486 gitlabToken : String ,
@@ -93,13 +95,15 @@ class LintContext : Middleware {
9395 fileText = pass.file.text
9496 }
9597
96- return gitlab.lintContent(
97- gitlabUrl,
98- gitlabToken,
99- fileText,
100- remoteId,
101- branch,
102- showGitlabTokenNotification
103- ).get()
98+ return withContext(Dispatchers .IO ) {
99+ gitlab.lintContent(
100+ gitlabUrl,
101+ gitlabToken,
102+ fileText,
103+ remoteId,
104+ branch,
105+ showGitlabTokenNotification
106+ ).get()
107+ }
104108 }
105109}
Original file line number Diff line number Diff line change @@ -17,6 +17,8 @@ import com.intellij.openapi.components.service
1717import git4idea.repo.GitRemote
1818import git4idea.repo.GitRepository
1919import git4idea.repo.GitRepositoryManager
20+ import kotlinx.coroutines.Dispatchers
21+ import kotlinx.coroutines.withContext
2022
2123@Service(Service .Level .PROJECT )
2224class ResolveContext : Middleware {
@@ -75,8 +77,10 @@ class ResolveContext : Middleware {
7577 }
7678 }
7779
78- private fun locateRepository (pass : Pass ): GitRepository ? {
79- val repository = GitRepositoryManager .getInstance(pass.project).getRepositoryForFile(pass.file.virtualFile)
80+ private suspend fun locateRepository (pass : Pass ): GitRepository ? {
81+ val repository = withContext(Dispatchers .IO ) {
82+ GitRepositoryManager .getInstance(pass.project).getRepositoryForFile(pass.file.virtualFile)
83+ }
8084
8185 showRepositoryNotification = if (repository == null ) {
8286 sendNotification(Notification .repositoryNotFound(), pass.project)
You can’t perform that action at this time.
0 commit comments