Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plugin UI. UnsupportedOperationException is thrown when new test sour… #939

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import com.intellij.openapi.module.ModuleUtil
import com.intellij.openapi.project.Project
import com.intellij.openapi.projectRoots.JavaSdkVersion
import com.intellij.openapi.vfs.VirtualFile
import com.intellij.openapi.vfs.newvfs.impl.FakeVirtualFile
import com.intellij.psi.PsiClass
import com.intellij.refactoring.util.classMembers.MemberInfo
import org.jetbrains.kotlin.idea.core.getPackage
Expand All @@ -41,7 +42,15 @@ data class GenerateTestsModel(
fun setSourceRootAndFindTestModule(newTestSourceRoot: VirtualFile?) {
requireNotNull(newTestSourceRoot)
testSourceRoot = newTestSourceRoot
testModule = ModuleUtil.findModuleForFile(newTestSourceRoot, project)
var target = newTestSourceRoot
while(target != null && target is FakeVirtualFile) {
target = target.parent
}
if (target == null) {
error("Could not find module for $newTestSourceRoot")
}

testModule = ModuleUtil.findModuleForFile(target, project)
?: error("Could not find module for $newTestSourceRoot")
}

Expand Down