Skip to content

Commit

Permalink
update constants in the ide state keeper
Browse files Browse the repository at this point in the history
  • Loading branch information
diffitask committed Nov 17, 2023
1 parent 5ce6e11 commit 82cc204
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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
}

Expand All @@ -50,6 +56,4 @@ class IdeStateKeeper(val userProject: Project) {
}
return apiMethodsCount
}
}

const val DEFAULT_API_METHODS_COUNT_TO_REVERSE = 1
}

0 comments on commit 82cc204

Please sign in to comment.