Skip to content

Commit

Permalink
feat(test): make it works
Browse files Browse the repository at this point in the history
  • Loading branch information
phodal committed Jul 26, 2023
1 parent 8ddf6a0 commit fe3cecc
Showing 1 changed file with 2 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import cc.unitmesh.devti.context.ClassContextProvider
import cc.unitmesh.devti.provider.TestContextProvider
import cc.unitmesh.devti.provider.TestFileContext
import com.intellij.openapi.diagnostic.logger
import com.intellij.openapi.externalSystem.service.project.ProjectDataManager
import com.intellij.openapi.project.Project
import com.intellij.openapi.project.guessProjectDir
import com.intellij.openapi.vfs.LocalFileSystem
Expand Down Expand Up @@ -57,17 +58,12 @@ class JavaTestContextProvider : TestContextProvider() {
}

private fun prepareModels(sourceFile: PsiJavaFile, project: Project, element: PsiElement): List<ClassContext> {
// 1. if element is method, find input and output Class, 2. find method call from fields
val models = mutableListOf<ClassContext>()
val allImports = sourceFile.importList?.allImportStatements?.map {
it.importReference?.text
}?.filterNotNull().orEmpty()

if (element is PsiMethod) {
val inputTypes = element.parameterList.parameters.map {
it.type is PsiClassType
}.filterIsInstance<PsiClassType>().filter {
allImports.contains(it.canonicalText)
it.resolve()?.containingFile?.virtualFile?.path?.contains(project.guessProjectDir()?.path!!)!!
}.map { it.resolve()!! }

// find input class from inputTypes
Expand Down

0 comments on commit fe3cecc

Please sign in to comment.