File tree 2 files changed +11
-3
lines changed
utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin
2 files changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -271,7 +271,7 @@ object UtTestsDialogProcessor {
271
271
val name = qualifiedName
272
272
?.substringAfter(" $packageName ." )
273
273
?.replace(" ." , " $" )
274
- ? : " "
274
+ ? : error( " Unable to get canonical name for $this " )
275
275
" $packageName .$name "
276
276
}
277
277
}
Original file line number Diff line number Diff line change @@ -17,8 +17,9 @@ import com.intellij.openapi.projectRoots.JavaSdkVersion
17
17
import com.intellij.openapi.vfs.VirtualFile
18
18
import com.intellij.openapi.vfs.newvfs.impl.FakeVirtualFile
19
19
import com.intellij.psi.PsiClass
20
+ import com.intellij.psi.PsiJavaFile
20
21
import com.intellij.refactoring.util.classMembers.MemberInfo
21
- import org.jetbrains.kotlin.idea.core.getPackage
22
+ import org.jetbrains.kotlin.psi.KtFile
22
23
import org.utbot.framework.plugin.api.JavaDocCommentStyle
23
24
import org.utbot.framework.util.ConflictTriggers
24
25
import org.utbot.intellij.plugin.ui.utils.jdkVersion
@@ -84,4 +85,11 @@ data class GenerateTestsModel(
84
85
}
85
86
}
86
87
87
- val PsiClass .packageName: String get() = this .containingFile.containingDirectory.getPackage()?.qualifiedName ? : " "
88
+ val PsiClass .packageName: String
89
+ get() {
90
+ return when (val currentFile = containingFile) {
91
+ is PsiJavaFile -> currentFile.packageName
92
+ is KtFile -> currentFile.packageFqName.asString()
93
+ else -> error(" Can't find package name for $this : it should be located either in Java or Kt file" )
94
+ }
95
+ }
You can’t perform that action at this time.
0 commit comments