diff --git a/buildSrc/src/main/kotlin/Versions.kt b/buildSrc/src/main/kotlin/Versions.kt index bbba0ecbc..d85884b68 100644 --- a/buildSrc/src/main/kotlin/Versions.kt +++ b/buildSrc/src/main/kotlin/Versions.kt @@ -20,8 +20,8 @@ object Versions { const val kotlinCompiler = "1.4.21" const val kotlinStdlib = "1.4.21" - const val kotlinIntellijPlugin = "203-1.4.21-release-IJ5981.133" // keep to newest as kotlinCompiler - const val intellij = "2020.3" // don't update easily unless you want your disk space -= 500MB + const val kotlinIntellijPlugin = "211-1.4.32-release-IJ6693.72" // keep to newest as kotlinCompiler + const val intellij = "2021.1" // don't update easily unless you want your disk space -= 500MB const val coroutines = "1.4.0" @@ -40,7 +40,7 @@ object Versions { @Suppress("SpellCheckingInspection") const val yamlkt = "0.7.5" - const val intellijGradlePlugin = "0.4.16" + const val intellijGradlePlugin = "0.7.2" } const val `kotlin-compiler` = "org.jetbrains.kotlin:kotlin-compiler:${Versions.kotlinCompiler}" diff --git a/tools/intellij-plugin/src/creator/build/ProjectCreator.kt b/tools/intellij-plugin/src/creator/build/ProjectCreator.kt index 9dd38e8e3..154c23763 100644 --- a/tools/intellij-plugin/src/creator/build/ProjectCreator.kt +++ b/tools/intellij-plugin/src/creator/build/ProjectCreator.kt @@ -15,7 +15,6 @@ import com.intellij.openapi.module.Module import com.intellij.openapi.progress.ProgressIndicator import com.intellij.openapi.vfs.VfsUtil import com.intellij.openapi.vfs.VirtualFile -import com.intellij.testFramework.writeChild import net.mamoe.mirai.console.intellij.assets.FT import net.mamoe.mirai.console.intellij.creator.MiraiProjectModel import net.mamoe.mirai.console.intellij.creator.tasks.getTemplate @@ -24,6 +23,7 @@ import net.mamoe.mirai.console.intellij.creator.tasks.runWriteActionAndWait import net.mamoe.mirai.console.intellij.creator.tasks.writeChild import net.mamoe.mirai.console.intellij.creator.templateProperties import org.jetbrains.kotlin.idea.core.util.toPsiFile +import java.nio.file.Path sealed class ProjectCreator( val module: Module, @@ -36,11 +36,11 @@ sealed class ProjectCreator( model.checkValuesNotNull() } - protected val filesChanged = mutableListOf() + protected val filesChanged = mutableListOf() @Synchronized - protected fun addFileChanged(vf: VirtualFile) { - filesChanged.add(vf) + protected fun addFileChanged(path: Path) { + filesChanged.add(path) } protected fun getTemplate(name: String) = project.getTemplate(name, model.templateProperties) @@ -49,7 +49,7 @@ sealed class ProjectCreator( indicator.text2 = "Reformatting files" invokeAndWait { for (file in filesChanged) { - val psi = file.toPsiFile(project) ?: continue + val psi = file.toFile().toPsiFile(project) ?: continue ReformatCodeProcessor(psi, false).run() } } @@ -69,13 +69,14 @@ sealed class GradleProjectCreator( runWriteActionAndWait { VfsUtil.createDirectoryIfMissing(root, "src/main/${model.languageType.sourceSetDirName}") VfsUtil.createDirectoryIfMissing(root, "src/main/resources") - filesChanged += root.writeChild(model.languageType.pluginMainClassFile(this)) - filesChanged += root.writeChild("src/main/resources/META-INF/services/net.mamoe.mirai.console.plugin.jvm.JvmPlugin", model.mainClassQualifiedName) - filesChanged += root.writeChild("gradle.properties", getTemplate(FT.GradleProperties)) + addFileChanged(root.writeChild(model.languageType.pluginMainClassFile(this))) + addFileChanged(root.writeChild("src/main/resources/META-INF/services/net.mamoe.mirai.console.plugin.jvm.JvmPlugin", model.mainClassQualifiedName)) + addFileChanged(root.writeChild("gradle.properties", getTemplate(FT.GradleProperties))) } } } + class GradleKotlinProjectCreator( module: Module, root: VirtualFile, model: MiraiProjectModel, ) : GradleProjectCreator( @@ -84,8 +85,8 @@ class GradleKotlinProjectCreator( override fun createProject(module: Module, root: VirtualFile, model: MiraiProjectModel) { super.createProject(module, root, model) runWriteActionAndWait { - filesChanged += root.writeChild("build.gradle.kts", getTemplate(FT.BuildGradleKts)) - filesChanged += root.writeChild("settings.gradle.kts", getTemplate(FT.SettingsGradleKts)) + addFileChanged(root.writeChild("build.gradle.kts", getTemplate(FT.BuildGradleKts))) + addFileChanged(root.writeChild("settings.gradle.kts", getTemplate(FT.SettingsGradleKts))) } } } @@ -98,8 +99,8 @@ class GradleGroovyProjectCreator( override fun createProject(module: Module, root: VirtualFile, model: MiraiProjectModel) { super.createProject(module, root, model) runWriteActionAndWait { - filesChanged += root.writeChild("build.gradle", getTemplate(FT.BuildGradle)) - filesChanged += root.writeChild("settings.gradle", getTemplate(FT.SettingsGradle)) + addFileChanged(root.writeChild("build.gradle", getTemplate(FT.BuildGradle))) + addFileChanged(root.writeChild("settings.gradle", getTemplate(FT.SettingsGradle))) } } } \ No newline at end of file diff --git a/tools/intellij-plugin/src/creator/tasks/TaskUtils.kt b/tools/intellij-plugin/src/creator/tasks/TaskUtils.kt index 2b76d5086..e35f5a0dc 100644 --- a/tools/intellij-plugin/src/creator/tasks/TaskUtils.kt +++ b/tools/intellij-plugin/src/creator/tasks/TaskUtils.kt @@ -18,7 +18,7 @@ import com.intellij.openapi.project.Project import com.intellij.openapi.vfs.LocalFileSystem import com.intellij.openapi.vfs.VfsUtil import com.intellij.openapi.vfs.VirtualFile -import com.intellij.testFramework.writeChild +import com.intellij.util.io.writeChild import net.mamoe.mirai.console.intellij.creator.steps.NamedFile import org.intellij.lang.annotations.Language import java.nio.file.Path @@ -81,7 +81,13 @@ fun Project.getTemplate( ): String = getTemplate(templateName, properties.toMap()) -fun VirtualFile.writeChild(namedFile: NamedFile): VirtualFile = this.writeChild(namedFile.path, namedFile.content) +internal fun VirtualFile.writeChild(pluginMainClassFile: NamedFile): Path { + return writeChild(pluginMainClassFile.path, pluginMainClassFile.content) +} + +internal fun VirtualFile.writeChild(path: String, content: String): Path { + return toNioPath().writeChild(path, content) +} @Language("RegExp") const val CLASS_NAME_PATTERN = "[a-zA-Z]+[0-9a-zA-Z_]*" // self written diff --git a/tools/intellij-plugin/src/diagnostics/fix/ConfigurePluginMainServiceFix.kt b/tools/intellij-plugin/src/diagnostics/fix/ConfigurePluginMainServiceFix.kt index 12fe290d1..0c638a5fd 100644 --- a/tools/intellij-plugin/src/diagnostics/fix/ConfigurePluginMainServiceFix.kt +++ b/tools/intellij-plugin/src/diagnostics/fix/ConfigurePluginMainServiceFix.kt @@ -16,8 +16,8 @@ import com.intellij.openapi.project.rootManager import com.intellij.openapi.vfs.VfsUtil import com.intellij.psi.PsiElement import com.intellij.psi.PsiFile -import com.intellij.testFramework.writeChild import net.mamoe.mirai.console.intellij.creator.tasks.readChildText +import net.mamoe.mirai.console.intellij.creator.tasks.writeChild import org.jetbrains.kotlin.idea.core.isAndroidModule import org.jetbrains.kotlin.idea.inspections.KotlinUniversalQuickFix import org.jetbrains.kotlin.idea.quickfix.KotlinCrossLanguageQuickFixAction