mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-02-04 23:39:07 +07:00
AT-225 Move doc to class, throw test exceptions instead of default npes
GitOrigin-RevId: f58409224bd32b62956ec514e42661a6abdc4162
This commit is contained in:
committed by
intellij-monorepo-bot
parent
176ba3cadc
commit
e2df07819f
@@ -1,8 +0,0 @@
|
||||
<html>
|
||||
<title>Command to add Java file to project</title>
|
||||
<body>
|
||||
<p>
|
||||
Example: %createJavaFile [fileName],[dstDir],[fileType - class, enum, annotation, record, interface]
|
||||
</p>
|
||||
</body>
|
||||
</html>
|
||||
@@ -10,6 +10,10 @@ import com.intellij.psi.JavaDirectoryService
|
||||
import com.intellij.psi.impl.file.PsiJavaDirectoryFactory
|
||||
import com.jetbrains.performancePlugin.commands.PerformanceCommandCoroutineAdapter
|
||||
|
||||
/**
|
||||
* Command to add Java file to project
|
||||
* Example: %createJavaFile fileName,dstDir,fileType - class, enum, annotation, record, interface
|
||||
*/
|
||||
class CreateJavaFileCommand(text: String, line: Int) : PerformanceCommandCoroutineAdapter(text, line) {
|
||||
|
||||
companion object {
|
||||
@@ -29,10 +33,13 @@ class CreateJavaFileCommand(text: String, line: Int) : PerformanceCommandCorouti
|
||||
|
||||
val directory = PsiJavaDirectoryFactory
|
||||
.getInstance(context.project)
|
||||
.createDirectory(context.project.guessProjectDir()!!.findFileOrDirectory(filePath)!!)
|
||||
.createDirectory(
|
||||
(context.project.guessProjectDir() ?: throw RuntimeException("'guessProjectDir' dir returned 'null'"))
|
||||
.findFileOrDirectory(filePath) ?: throw RuntimeException("Can't find file $filePath")
|
||||
)
|
||||
|
||||
val templateName = POSSIBLE_FILE_TYPES.getOrElse(fileType.lowercase()) { return@getOrElse null }
|
||||
if (templateName == null) throw RuntimeException("File type must be one of ${POSSIBLE_FILE_TYPES.keys}")
|
||||
val templateName = POSSIBLE_FILE_TYPES[fileType.lowercase()]
|
||||
if (templateName == null) throw RuntimeException("File type must be one of '${POSSIBLE_FILE_TYPES.keys}'")
|
||||
|
||||
ApplicationManager.getApplication().invokeAndWait {
|
||||
ApplicationManager.getApplication().getService(JavaDirectoryService::class.java)
|
||||
|
||||
Reference in New Issue
Block a user