Code review 107358 resolve issues

GitOrigin-RevId: d86947841925d0fc238cec1f3f735519e66c32e5
This commit is contained in:
Alexey Kryuchkov
2023-07-03 00:34:02 +04:00
committed by intellij-monorepo-bot
parent c8162203b2
commit 6ab4e94b06
2 changed files with 9 additions and 6 deletions

View File

@@ -5,6 +5,7 @@ import com.intellij.core.JavaPsiBundle.message
import com.intellij.openapi.application.ApplicationManager
import com.intellij.openapi.project.guessProjectDir
import com.intellij.openapi.ui.playback.PlaybackContext
import com.intellij.openapi.vfs.findDirectory
import com.intellij.platform.diagnostic.telemetry.helpers.useWithScope
import com.intellij.psi.JavaDirectoryService
import com.intellij.psi.impl.file.PsiJavaDirectoryFactory
@@ -38,8 +39,8 @@ class CreateJavaFileCommand(text: String, line: Int) : PerformanceCommandCorouti
val directory = PsiJavaDirectoryFactory
.getInstance(context.project)
.createDirectory(
(context.project.guessProjectDir() ?: throw RuntimeException("'guessProjectDir' dir returned 'null'"))
.findFileByRelativePath(filePath) ?: throw RuntimeException("Can't find file $filePath")
(context.project.guessProjectDir() ?: throw RuntimeException("Root of the project was not found"))
.findDirectory(filePath) ?: throw RuntimeException("Can't find file $filePath")
)
val templateName = POSSIBLE_FILE_TYPES[fileType.lowercase()]