Skip to content

Commit

Permalink
refactor(java): rename method for clarity
Browse files Browse the repository at this point in the history
Renamed `findSimilarTestCases` to `searchSimilarTestCases` for better clarity and consistency. Updated all references accordingly.
  • Loading branch information
phodal committed Jul 2, 2024
1 parent 8548ec8 commit 75b58de
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class JavaPsiContextVariableProvider : PsiContextVariableProvider {
}

PsiContextVariable.SIMILAR_TEST_CASE -> {
JavaTestHelper.findSimilarTestCases(psiElement).joinToString("\n") { it.text }
JavaTestHelper.searchSimilarTestCases(psiElement).joinToString("\n") { it.text }
}

PsiContextVariable.IS_NEED_CREATE_FILE -> TestFinderHelper.findClassesForTest(psiElement).isEmpty()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package com.phodal.shirelang.java.variable

import com.intellij.openapi.project.Project
import com.intellij.psi.PsiElement
import com.intellij.psi.PsiJavaFile
import com.intellij.psi.PsiMethod
import com.intellij.psi.PsiMethodCallExpression
import com.intellij.psi.search.GlobalSearchScope
Expand Down Expand Up @@ -39,7 +38,7 @@ object JavaTestHelper {
}
}

fun findSimilarTestCases(psiElement: PsiElement, minScore: Double = 1.0): List<PsiMethod> {
fun searchSimilarTestCases(psiElement: PsiElement, minScore: Double = 1.0): List<PsiMethod> {
val project = psiElement.project
val psiMethod = psiElement as? PsiMethod ?: return emptyList()
val methodName = psiMethod.name
Expand All @@ -59,7 +58,13 @@ object JavaTestHelper {
}
}

fun getAllTestMethods(project: Project): List<PsiMethod> {
/**
* Retrieves all test methods from the given project.
*
* @param project the project from which to retrieve the test methods
* @return a list of PsiMethod objects representing all test methods found in the project
*/
private fun getAllTestMethods(project: Project): List<PsiMethod> {
val cachedValue: CachedValue<List<PsiMethod>> = CachedValuesManager.getManager(project).createCachedValue {
val testMethods = mutableListOf<PsiMethod>()
val scope = GlobalSearchScope.projectScope(project)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public class MathHelperTest {

val addMethod = psiFile2.classes.first().methods.first() as PsiMethod

val testCases = JavaTestHelper.findSimilarTestCases(addMethod)
val testCases = JavaTestHelper.searchSimilarTestCases(addMethod)
TestCase.assertEquals(2, testCases.size)
}
}

0 comments on commit 75b58de

Please sign in to comment.