Skip to content

Commit 668b098

Browse files
committed
refactor(container): simplify Dockerfile detection logic #306
Remove unnecessary `runReadAction` and `PsiManager` usage, and simplify the `isApplicable` method by directly checking the file extension
1 parent be74706 commit 668b098

File tree

1 file changed

+2
-9
lines changed

1 file changed

+2
-9
lines changed

exts/ext-container/src/241/main/kotlin/cc/unitmesh/container/RunDockerfileService.kt

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,17 @@ import com.intellij.docker.deploymentSource.DockerImageDeploymentSourceType
99
import com.intellij.docker.runtimes.DockerServerRuntime
1010
import com.intellij.execution.configurations.RunConfiguration
1111
import com.intellij.execution.configurations.RunProfile
12-
import com.intellij.openapi.application.runReadAction
1312
import com.intellij.openapi.project.Project
1413
import com.intellij.openapi.vfs.VirtualFile
15-
import com.intellij.psi.PsiManager
1614
import com.intellij.remoteServer.ServerType
1715
import com.intellij.remoteServer.configuration.RemoteServer
1816
import com.intellij.remoteServer.configuration.RemoteServersManager
1917
import kotlinx.coroutines.future.await
2018

2119
class RunDockerfileService : RunService {
2220
override fun isApplicable(project: Project, file: VirtualFile): Boolean {
23-
if (file.name == "Dockerfile") {
24-
return true
25-
}
26-
27-
return runReadAction {
28-
PsiManager.getInstance(project).findFile(file)?.language?.displayName == "Dockerfile"
29-
}
21+
if (file.name == "Dockerfile") return true
22+
return file.extension == "Dockerfile"
3023
}
3124

3225
override fun runConfigurationClass(project: Project): Class<out RunProfile>? = null

0 commit comments

Comments
 (0)