From 82cc20414d04759f9166e23d3e4d497648b50e0a Mon Sep 17 00:00:00 2001 From: "Evgeniia.Fedotova" Date: Fri, 17 Nov 2023 10:44:04 +0100 Subject: [PATCH] update constants in the ide state keeper --- .../ideFormerPlugin/api/models/utils/ApiUtils.kt | 2 ++ .../ideFormerPlugin/stateKeeper/IdeStateKeeper.kt | 14 +++++++++----- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/ide-former-plugin/ide-core/src/main/kotlin/org/jetbrains/research/ideFormerPlugin/api/models/utils/ApiUtils.kt b/ide-former-plugin/ide-core/src/main/kotlin/org/jetbrains/research/ideFormerPlugin/api/models/utils/ApiUtils.kt index 3d4e5f6..d176958 100644 --- a/ide-former-plugin/ide-core/src/main/kotlin/org/jetbrains/research/ideFormerPlugin/api/models/utils/ApiUtils.kt +++ b/ide-former-plugin/ide-core/src/main/kotlin/org/jetbrains/research/ideFormerPlugin/api/models/utils/ApiUtils.kt @@ -10,6 +10,8 @@ const val DEFAULT_DIRECTORY_NAME = "." const val UNCALLED_EXECUTE_BEFORE_RESULT_GETTING = "Execute() must be called before getting the result. The property storing the result has not been initialized yet" const val UNSUPPORTED_FILE_EXTENSION_ERROR = "Unsupported file extension: only .py, .kt, .java file can be processed" +const val NO_GIT_ROOTS = "No git roots was found" +const val NO_GIT_REPO_FOR_PROJECT = "No git repository was found for the project" enum class FileExtensions(val extension: String) { KT("kt"), diff --git a/ide-former-plugin/ide-core/src/main/kotlin/org/jetbrains/research/ideFormerPlugin/stateKeeper/IdeStateKeeper.kt b/ide-former-plugin/ide-core/src/main/kotlin/org/jetbrains/research/ideFormerPlugin/stateKeeper/IdeStateKeeper.kt index e18b933..291faa9 100644 --- a/ide-former-plugin/ide-core/src/main/kotlin/org/jetbrains/research/ideFormerPlugin/stateKeeper/IdeStateKeeper.kt +++ b/ide-former-plugin/ide-core/src/main/kotlin/org/jetbrains/research/ideFormerPlugin/stateKeeper/IdeStateKeeper.kt @@ -12,6 +12,8 @@ import git4idea.actions.GitPull import git4idea.branch.GitBranchUtil import git4idea.repo.GitRepository import org.jetbrains.research.ideFormerPlugin.api.models.ReversibleApiMethod +import org.jetbrains.research.ideFormerPlugin.api.models.utils.NO_GIT_REPO_FOR_PROJECT +import org.jetbrains.research.ideFormerPlugin.api.models.utils.NO_GIT_ROOTS import java.util.* class IdeStateKeeper(val userProject: Project) { @@ -21,13 +23,17 @@ class IdeStateKeeper(val userProject: Project) { private val projectGitRepo: GitRepository val projectGitRoot: VirtualFile + companion object { + const val DEFAULT_API_METHODS_COUNT_TO_REVERSE = 1 + } + init { val gitVcs = GitVcs.getInstance(userProject) val gitRoots = GitPull.getGitRoots(userProject, gitVcs) - if (gitRoots.isNullOrEmpty()) error("No git roots was found") + if (gitRoots.isNullOrEmpty()) error(NO_GIT_ROOTS) projectGitRepo = GitBranchUtil.guessRepositoryForOperation(userProject, DataContext.EMPTY_CONTEXT) - ?: error("No git repository was found for user project") + ?: error(NO_GIT_REPO_FOR_PROJECT) projectGitRoot = projectGitRepo.root } @@ -50,6 +56,4 @@ class IdeStateKeeper(val userProject: Project) { } return apiMethodsCount } -} - -const val DEFAULT_API_METHODS_COUNT_TO_REVERSE = 1 \ No newline at end of file +} \ No newline at end of file