diff --git a/build.gradle.kts b/build.gradle.kts index 2a93e4d4..f4adef72 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,9 +1,10 @@ plugins { - id("org.jetbrains.kotlin.jvm") version "1.8.21" - id("org.jetbrains.intellij") version "1.13.3" + id("org.jetbrains.kotlin.jvm") version "1.9.0-RC" + id("org.jetbrains.intellij") version "1.15.0" + id("org.jetbrains.kotlin.plugin.serialization") version "1.8.21" } group = "shop.itbug" -version = "3.3.3.as" +version = "3.5.0.eap" repositories { mavenCentral() google() @@ -16,15 +17,15 @@ repositories { intellij { - version.set("2022.2.1.18") - type.set("AI") + version.set("LATEST-EAP-SNAPSHOT") + type.set("IC") plugins.set( listOf( "yaml", - "Dart:222.4582", - "io.flutter:73.0.2", + "Dart:232.8660.129", + "io.flutter:74.0.5", "org.intellij.plugins.markdown", - "terminal", "java" + "terminal", "java", "maven" ) ) } @@ -35,92 +36,40 @@ kotlin { languageVersion = "2.0" } } + + } -/// dependencies { - implementation("com.squareup.retrofit2:retrofit:2.9.0") { - exclude(group = "org.jetbrains.kotlinx") - exclude(group = "org.slf4j") - exclude(group = "org.jetbrains.kotlin") - } + implementation("com.squareup.retrofit2:retrofit:2.9.0") implementation("com.squareup.retrofit2:converter-gson:2.9.0") - { - exclude(group = "org.jetbrains.kotlinx") - exclude(group = "org.slf4j") - exclude(group = "org.jetbrains.kotlin") - } implementation("com.github.ben-manes.caffeine:caffeine:3.1.5") - { - exclude(group = "org.jetbrains.kotlinx") - exclude(group = "org.slf4j") - exclude(group = "org.jetbrains.kotlin") - } - implementation("cn.hutool:hutool-all:5.8.15") { - exclude(group = "org.jetbrains.kotlinx") - exclude(group = "org.slf4j") - exclude(group = "org.jetbrains.kotlin") - } - implementation("org.smartboot.socket:aio-core:1.6.3") { - exclude(group = "org.jetbrains.kotlinx") - exclude(group = "org.slf4j") - exclude(group = "org.jetbrains.kotlin") - } + implementation("cn.hutool:hutool-all:5.8.15") + implementation("org.smartboot.socket:aio-core:1.6.3") implementation("com.alibaba.fastjson2:fastjson2:2.0.25") - { - exclude(group = "org.jetbrains.kotlinx") - exclude(group = "org.slf4j") - exclude(group = "org.jetbrains.kotlin") - } implementation("com.alibaba.fastjson2:fastjson2-kotlin:2.0.25") - { - exclude(group = "org.jetbrains.kotlinx") - exclude(group = "org.slf4j") - exclude(group = "org.jetbrains.kotlin") - } implementation("org.apache.commons:commons-lang3:3.12.0") - { - exclude(group = "org.jetbrains.kotlinx") - exclude(group = "org.slf4j") - exclude(group = "org.jetbrains.kotlin") - } - implementation("com.google.code.gson:gson:2.10.1") { - exclude(group = "org.jetbrains.kotlinx") - exclude(group = "org.slf4j") - exclude(group = "org.jetbrains.kotlin") - } - implementation("com.fasterxml.jackson.core:jackson-databind:2.14.2") { - exclude(group = "org.jetbrains.kotlinx") - exclude(group = "org.slf4j") - exclude(group = "org.jetbrains.kotlin") - } - implementation("org.xerial:sqlite-jdbc:3.40.1.0") { - exclude(group = "org.jetbrains.kotlinx") - exclude(group = "org.slf4j") - exclude(group = "org.jetbrains.kotlin") - } - implementation("com.aallam.openai:openai-client:3.2.0") { - exclude(group = "org.jetbrains.kotlinx") - exclude(group = "org.slf4j") - exclude(group = "org.jetbrains.kotlin") - } - implementation("io.ktor:ktor-client-cio-jvm:2.2.4") { - exclude(group = "org.jetbrains.kotlinx") - exclude(group = "org.slf4j") - exclude(group = "org.jetbrains.kotlin") - } + implementation("com.google.code.gson:gson:2.10.1") + implementation("com.fasterxml.jackson.core:jackson-databind:2.14.2") + implementation("org.xerial:sqlite-jdbc:3.40.1.0") + implementation("io.ktor:ktor-client-cio-jvm:2.2.4") + implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.5.1") } + + + var javaVersion = "17" tasks { - withType { - kotlinOptions.jvmTarget = javaVersion - } withType().configureEach { + kotlinOptions.jvmTarget = javaVersion kotlinOptions.freeCompilerArgs += "-opt-in=kotlin.RequiresOptIn" compilerOptions.languageVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_1_9) + compilerOptions { + + } } listProductsReleases { @@ -128,9 +77,40 @@ tasks { patchPluginXml { sinceBuild.set("222") - untilBuild.set("222.*") changeNotes.set( """ +
+

3.5.0.eap (2023-07-25)

+
    +
  • 添加freezed快捷操作菜单
  • +
  • 新增韩语,日语,繁体等多国语言
  • +
  • 其他若干细节优化
  • +
+
    +
  • freezedショートカットメニューの追加
  • +
  • 韓国語、日本語、繁体字など多言語を追加
  • +
  • その他の詳細の最適化
  • +
+
    +
  • freezed 바로 가기 메뉴 추가
  • +
  • 한국어, 일본어, 번체 등 다국어 추가
  • +
  • 기타 몇 가지 세부 최적화
  • +
+
+
+

3.4.1.221

+
    +
  • Fix bug that cannot be enabled in version 3.4.0.221
  • +
+
+
+

3.4.0.221

+
    +
  • Adaptation 221
  • +
  • New: Flutter version detection
  • +
  • New: Community Link Entry
  • +
+

3.3.3.as

    @@ -328,9 +308,4 @@ tasks { } } -configurations.all { - exclude(group = "io.ktor", module = "kotlinx-coroutines-jdk8") - exclude(group = "io.ktor", module = "kotlinx-coroutines-core") - exclude(group = "com.aallam.openai", module = "kotlinx-coroutines-jdk8") - exclude(group = "com.aallam.openai", module = "kotlinx-coroutines-core") -} + diff --git a/gradle.properties b/gradle.properties index c4a31bae..17c81963 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,2 +1,3 @@ kotlin.stdlib.default.dependency = true -kotlin.incremental.useClasspathSnapshot=false \ No newline at end of file +kotlin.incremental.useClasspathSnapshot=false +kotlin.experimental.tryK2=true \ No newline at end of file diff --git a/src/main/kotlin/icons/MyIcons.kt b/src/main/kotlin/icons/MyIcons.kt index dcffa088..d17c09ec 100644 --- a/src/main/kotlin/icons/MyIcons.kt +++ b/src/main/kotlin/icons/MyIcons.kt @@ -11,6 +11,10 @@ object MyImages { @JvmField val test : Icon = load("/images/test.png") + + + + @JvmStatic fun load(path: String): Icon { return IconLoader.getIcon(path, MyImages::class.java) diff --git a/src/main/kotlin/note/jdbc/FlutterCollectService.kt b/src/main/kotlin/note/jdbc/FlutterCollectService.kt index ea18cf48..f780baff 100644 --- a/src/main/kotlin/note/jdbc/FlutterCollectService.kt +++ b/src/main/kotlin/note/jdbc/FlutterCollectService.kt @@ -130,16 +130,4 @@ object FlutterCollectService { } - - - - ///禁用检查 - fun disableCheckPlugin( pluginName: String,check: Boolean) { - check { - val sql = """ - - """.trimIndent() - } - } - } \ No newline at end of file diff --git a/src/main/kotlin/note/setting/InitFlutterPluginSettingDialog.kt b/src/main/kotlin/note/setting/InitFlutterPluginSettingDialog.kt index e5c1db40..ebcd00ff 100644 --- a/src/main/kotlin/note/setting/InitFlutterPluginSettingDialog.kt +++ b/src/main/kotlin/note/setting/InitFlutterPluginSettingDialog.kt @@ -1,5 +1,7 @@ package note.setting +import com.intellij.execution.filters.TextConsoleBuilderFactory +import com.intellij.execution.ui.ConsoleViewContentType import com.intellij.openapi.project.Project import com.intellij.ui.dsl.builder.panel import note.jdbc.SqliteConnectManager @@ -13,6 +15,7 @@ class InitFlutterPluginSettingDialog( override val project: Project) : MyDialogW init { super.init() title = "插件收藏" + } override fun createCenterPanel(): JComponent { diff --git a/src/main/kotlin/shop/itbug/fluttercheckversionx/actions/ApiCopyAll.kt b/src/main/kotlin/shop/itbug/fluttercheckversionx/actions/ApiCopyAll.kt index 6a56e34e..b92b726d 100644 --- a/src/main/kotlin/shop/itbug/fluttercheckversionx/actions/ApiCopyAll.kt +++ b/src/main/kotlin/shop/itbug/fluttercheckversionx/actions/ApiCopyAll.kt @@ -8,6 +8,9 @@ import shop.itbug.fluttercheckversionx.document.copyTextToClipboard class ApiCopyAll:MyAction({"Copy All"}) { override fun actionPerformed(e: AnActionEvent) { + + + val api = e.api()!! val dataMap = mutableMapOf( "url" to api.url, diff --git a/src/main/kotlin/shop/itbug/fluttercheckversionx/actions/IosFrameworkScanAction.kt b/src/main/kotlin/shop/itbug/fluttercheckversionx/actions/IosFrameworkScanAction.kt new file mode 100644 index 00000000..4963b806 --- /dev/null +++ b/src/main/kotlin/shop/itbug/fluttercheckversionx/actions/IosFrameworkScanAction.kt @@ -0,0 +1,118 @@ +package shop.itbug.fluttercheckversionx.actions + +import com.intellij.openapi.actionSystem.ActionUpdateThread +import com.intellij.openapi.actionSystem.AnAction +import com.intellij.openapi.actionSystem.AnActionEvent +import com.intellij.openapi.actionSystem.CommonDataKeys +import com.intellij.openapi.progress.ProgressIndicator +import com.intellij.openapi.progress.ProgressManager +import com.intellij.openapi.progress.Task +import com.intellij.openapi.project.Project +import com.intellij.openapi.ui.DialogPanel +import com.intellij.openapi.ui.DialogWrapper +import com.intellij.openapi.vfs.LocalFileSystem +import com.intellij.openapi.vfs.VfsUtilCore +import com.intellij.openapi.vfs.VirtualFile +import com.intellij.openapi.vfs.VirtualFileVisitor +import com.intellij.ui.dsl.builder.bindSelected +import com.intellij.ui.dsl.builder.bindText +import com.intellij.ui.dsl.builder.panel +import shop.itbug.fluttercheckversionx.document.copyTextToClipboard +import shop.itbug.fluttercheckversionx.util.toast +import shop.itbug.fluttercheckversionx.util.toastWithError +import javax.swing.JComponent + + +class IosFrameworkScanActionDialog(val project: Project, val e: AnActionEvent) : DialogWrapper(project) { + + data class ModelProperties(var scanDirectionPath: String, var extension: String, var isDirection: Boolean) + + val model = ModelProperties(scanDirectionPath = "/Framework", extension = "framework", isDirection = false) + + private lateinit var dialogPanel: DialogPanel + + init { + super.init() + title = "Flutter IOS Framework Util" + } + + override fun createCenterPanel(): JComponent { + dialogPanel = panel { + row("扫描目录") { + textField().bindText(model::scanDirectionPath) + } + row("模块后缀") { + textField().bindText(model::extension) + } + + row("是否目录") { + checkBox("是否为目录").bindSelected({ model.isDirection }, { model.isDirection = it }) + } + + } + return dialogPanel + } + + + override fun doOKAction() { + dialogPanel.apply() + startTask() + super.doOKAction() + } + + private fun startTask() { + val task = object : Task.Backgroundable(project, "正在扫描中ios Framework") { + override fun run(indicator: ProgressIndicator) { + startTask(project, e) + } + } + ProgressManager.getInstance().run(task) + } + + //开始任务 + fun startTask(project: Project, e: AnActionEvent) { + val file = e.getData(CommonDataKeys.VIRTUAL_FILE) + if (file != null) { + val frameworkDirection = LocalFileSystem.getInstance().findFileByPath(file.path + model.scanDirectionPath) + if (frameworkDirection != null && frameworkDirection.isDirectory) { + val sb = StringBuffer() + VfsUtilCore.visitChildrenRecursively(frameworkDirection, object : VirtualFileVisitor() { + override fun visitFile(file: VirtualFile): Boolean { + if (file.extension == model.extension) { + val path = file.path.replace(project.basePath + "/ios/", "") + sb.append("\"$path\",") + } + if (model.isDirection && file.name.endsWith(model.extension)) { + val path = file.path.replace(project.basePath + "/ios/", "") + sb.append("\"$path\",") + } + return super.visitFile(file) + } + + }) + + val finalString = sb.toString().removeSuffix(",") + finalString.copyTextToClipboard() + project.toast(finalString) + } else { + project.toastWithError("Framework directory not found") + } + } + } + +} + + +///扫描ios插件包的Framework +class IosFrameworkScanAction : AnAction() { + override fun actionPerformed(e: AnActionEvent) { + e.project?.let { + IosFrameworkScanActionDialog(it, e).show() + } + } + + + override fun getActionUpdateThread(): ActionUpdateThread { + return ActionUpdateThread.BGT + } +} \ No newline at end of file diff --git a/src/main/kotlin/shop/itbug/fluttercheckversionx/activity/FlutterProjectOpenActivity.kt b/src/main/kotlin/shop/itbug/fluttercheckversionx/activity/FlutterProjectOpenActivity.kt index a9fc833b..bb91b0f8 100644 --- a/src/main/kotlin/shop/itbug/fluttercheckversionx/activity/FlutterProjectOpenActivity.kt +++ b/src/main/kotlin/shop/itbug/fluttercheckversionx/activity/FlutterProjectOpenActivity.kt @@ -1,14 +1,27 @@ package shop.itbug.fluttercheckversionx.activity +import com.intellij.notification.NotificationGroupManager +import com.intellij.notification.NotificationType import com.intellij.openapi.Disposable +import com.intellij.openapi.actionSystem.ActionUpdateThread +import com.intellij.openapi.actionSystem.AnAction +import com.intellij.openapi.actionSystem.AnActionEvent import com.intellij.openapi.application.ApplicationManager +import com.intellij.openapi.progress.ProgressIndicator +import com.intellij.openapi.progress.ProgressManager +import com.intellij.openapi.progress.Task import com.intellij.openapi.project.Project -import com.intellij.openapi.startup.StartupActivity +import com.intellij.openapi.startup.ProjectActivity import com.intellij.openapi.vfs.VirtualFile import com.intellij.openapi.vfs.VirtualFileManager import com.intellij.openapi.vfs.newvfs.BulkFileListener import com.intellij.openapi.vfs.newvfs.events.VFileEvent +import io.flutter.sdk.FlutterSdk +import org.jetbrains.plugins.terminal.TerminalToolWindowManager import shop.itbug.fluttercheckversionx.config.GenerateAssetsClassConfig +import shop.itbug.fluttercheckversionx.icons.MyIcons +import shop.itbug.fluttercheckversionx.services.FlutterService +import shop.itbug.fluttercheckversionx.services.Release import shop.itbug.fluttercheckversionx.util.CacheUtil import shop.itbug.fluttercheckversionx.util.MyDartPsiElementUtil @@ -17,14 +30,13 @@ import shop.itbug.fluttercheckversionx.util.MyDartPsiElementUtil * 当项目打开的时候,会执行这个类的runActivity方法 * 在这里启动一个子线程去检测项目中的pubspec.yaml文件.并执行检测新版本 */ -class FlutterProjectOpenActivity : StartupActivity, Disposable { +class FlutterProjectOpenActivity : ProjectActivity, Disposable { /** * 项目在idea中打开时执行函数 * */ - private fun checkAndAutoGenFile(projectPath: String, file: VirtualFile, project: Project) { var filePath = file.canonicalPath filePath = filePath?.replace("$projectPath/", "") @@ -39,7 +51,9 @@ class FlutterProjectOpenActivity : StartupActivity, Disposable { } - fun execute(project: Project) { + + + fun run(project: Project) { ///监听assets资源目录更改事件 ApplicationManager.getApplication().messageBus.connect(this).subscribe(VirtualFileManager.VFS_CHANGES, object : BulkFileListener { @@ -65,14 +79,77 @@ class FlutterProjectOpenActivity : StartupActivity, Disposable { } - ///清理插件的数据缓存 private fun cleanPubPluginsCache() { CacheUtil.clean() } - override fun runActivity(p0: Project) { - execute(p0) + + override suspend fun execute(project: Project) { + run(project) + checkFlutterLastVersion(project) + } + + + /** + * 检测 flutter最新版本 + */ + private fun checkFlutterLastVersion(project: Project) { + ProgressManager.getInstance().run(object : Task.Backgroundable(project, "Detecting Flutter version...") { + override fun run(p0: ProgressIndicator) { + val currentFlutterVersion = FlutterSdk.getFlutterSdk(project)?.version + currentFlutterVersion?.let { + val version = FlutterService.getVersion() + version?.apply { + val release = releases.find { o -> o.hash == currentRelease.stable } + release?.let { r -> + if (r.version != it.versionText) { + println("has new version") + showTip(r,project) + } + } + } + } + } + }) } + /** + * 弹出通知 + */ + fun showTip(release: Release,project: Project) { + val createNotification = + NotificationGroupManager.getInstance().getNotificationGroup("flutter_version_check").createNotification( + "The new Flutter version is ready", + "Update to the latest version: ${release.version} (dart:${release.dartSDKVersion})", + NotificationType.INFORMATION, + ) + createNotification.setIcon(MyIcons.flutter) + + + + createNotification.addAction(object : AnAction("Upgrade") { + override fun actionPerformed(p0: AnActionEvent) { + TerminalToolWindowManager.getInstance(project).createLocalShellWidget(project.basePath,"flutter upgrade").executeCommand("flutter upgrade") + createNotification.hideBalloon() + } + + override fun update(e: AnActionEvent) { + e.presentation.icon = MyIcons.flutter + super.update(e) + } + + override fun getActionUpdateThread(): ActionUpdateThread { + return ActionUpdateThread.BGT + } + + },) + createNotification.addAction(object : AnAction("Cancel"){ + override fun actionPerformed(p0: AnActionEvent) { + createNotification.hideBalloon() + + } + }) + createNotification.notify(project) + } } \ No newline at end of file diff --git a/src/main/kotlin/shop/itbug/fluttercheckversionx/common/AnyExtend.kt b/src/main/kotlin/shop/itbug/fluttercheckversionx/common/AnyExtend.kt index ae017671..ff21d7b2 100644 --- a/src/main/kotlin/shop/itbug/fluttercheckversionx/common/AnyExtend.kt +++ b/src/main/kotlin/shop/itbug/fluttercheckversionx/common/AnyExtend.kt @@ -30,7 +30,6 @@ fun String.getVirtualFile(): VirtualFile? { fun Project.jsonToFreezedRun(jsonText: String) { try { - val jsonObject = JSON.parseObject(jsonText, JSONReader.Feature.SupportArrayToBean) val jsonObjectToFreezedCovertModelList = ModelToFreezedModelServiceImpl().jsonObjectToFreezedCovertModelList(jsonObject) diff --git a/src/main/kotlin/shop/itbug/fluttercheckversionx/common/MyAction.kt b/src/main/kotlin/shop/itbug/fluttercheckversionx/common/MyAction.kt index bc28ed2f..b88ad8e1 100644 --- a/src/main/kotlin/shop/itbug/fluttercheckversionx/common/MyAction.kt +++ b/src/main/kotlin/shop/itbug/fluttercheckversionx/common/MyAction.kt @@ -1,13 +1,11 @@ package shop.itbug.fluttercheckversionx.common -import com.intellij.openapi.actionSystem.* +import com.intellij.openapi.actionSystem.AnAction +import com.intellij.openapi.actionSystem.ToggleAction import com.intellij.openapi.actionSystem.ex.ComboBoxAction import com.intellij.openapi.project.DumbAwareAction -import shop.itbug.fluttercheckversionx.services.ItbugService -import shop.itbug.fluttercheckversionx.services.SERVICE import java.util.function.Supplier import javax.swing.Icon -import javax.swing.JComponent abstract class MyAction : AnAction { @@ -18,9 +16,6 @@ abstract class MyAction : AnAction { constructor(name: Supplier, icon: Icon) : super(name, icon) constructor(title: String, desc: String, icon: Icon) : super(title, desc, icon) - override fun getActionUpdateThread(): ActionUpdateThread { - return ActionUpdateThread.BGT - } } abstract class MyDumbAwareAction : DumbAwareAction { @@ -31,9 +26,6 @@ abstract class MyDumbAwareAction : DumbAwareAction { constructor(title: String, desc: String, icon: Icon) : super(title, desc, icon) - override fun getActionUpdateThread(): ActionUpdateThread { - return ActionUpdateThread.BGT - } } abstract class MyToggleAction : ToggleAction { @@ -43,14 +35,8 @@ abstract class MyToggleAction : ToggleAction { constructor(name: String, desc: String, icon: Icon) : super(name, desc, icon) - override fun getActionUpdateThread(): ActionUpdateThread { - return ActionUpdateThread.BGT - } } abstract class MyComboBoxAction : ComboBoxAction() { - override fun getActionUpdateThread(): ActionUpdateThread { - return ActionUpdateThread.BGT - } } \ No newline at end of file diff --git a/src/main/kotlin/shop/itbug/fluttercheckversionx/config/JsonToFreezedSetting.kt b/src/main/kotlin/shop/itbug/fluttercheckversionx/config/JsonToFreezedSetting.kt index ab0e48c8..b8050bea 100644 --- a/src/main/kotlin/shop/itbug/fluttercheckversionx/config/JsonToFreezedSetting.kt +++ b/src/main/kotlin/shop/itbug/fluttercheckversionx/config/JsonToFreezedSetting.kt @@ -1,6 +1,7 @@ package shop.itbug.fluttercheckversionx.config import com.intellij.openapi.components.PersistentStateComponent +import com.intellij.openapi.components.Service import com.intellij.openapi.components.State import com.intellij.openapi.components.Storage import com.intellij.openapi.project.Project @@ -24,6 +25,7 @@ data class JsonToFreezedSettingModel( * 状态存储 */ @State(name = "JsonToFreezedSettingModelConfig", storages = [Storage("JsonToFreezedSettingModelConfig.xml")]) +@Service(Service.Level.PROJECT) class JsonToFreezedSettingModelConfig : PersistentStateComponent { private var stateModel = JsonToFreezedSettingModel() override fun getState(): JsonToFreezedSettingModel { diff --git a/src/main/kotlin/shop/itbug/fluttercheckversionx/constance/StringConstance.kt b/src/main/kotlin/shop/itbug/fluttercheckversionx/constance/StringConstance.kt index fa4b0a4e..94862085 100644 --- a/src/main/kotlin/shop/itbug/fluttercheckversionx/constance/StringConstance.kt +++ b/src/main/kotlin/shop/itbug/fluttercheckversionx/constance/StringConstance.kt @@ -1,31 +1,4 @@ package shop.itbug.fluttercheckversionx.constance -val helpText = """ -# 安装依赖 - -在你的项目中添加插件依赖 -```yaml -dd_check_plugin: any #或者使用最新版 -``` - -# 初始化 - -在合适的地方进行初始化,Dio()换成你的自己的dio实例 - -```Dart -Future main() async { - await DdCheckPlugin.instance.init(Dio()); -} -``` - -# 注意 -```dart -interceptors.removeWhere((element) => element is! DioHttpRequestInterceptor);//单例模式下,请不要clean或者remove DioHttpRequestInterceptor -``` - -接入完成. -注意:第一次安装插件需要重启Idea -有问题请加Flutter自学QQ群:__${qqGroup.qqGroupNumber}__ - -""" \ No newline at end of file +const val discordUrl = "https://discord.gg/ethKNxKRcZ" \ No newline at end of file diff --git a/src/main/kotlin/shop/itbug/fluttercheckversionx/dialog/FreezedClassesGenerateDialog.kt b/src/main/kotlin/shop/itbug/fluttercheckversionx/dialog/FreezedClassesGenerateDialog.kt index feef96b8..29cce768 100644 --- a/src/main/kotlin/shop/itbug/fluttercheckversionx/dialog/FreezedClassesGenerateDialog.kt +++ b/src/main/kotlin/shop/itbug/fluttercheckversionx/dialog/FreezedClassesGenerateDialog.kt @@ -36,7 +36,6 @@ class FreezedClassesGenerateDialog( private val freezedClasses: MutableList ) : MyDialogWrapper(project) { - private val settingInstance = JsonToFreezedSettingModelConfig.getInstance(project) private val setting = settingInstance.state private val tabView = JBTabbedPane() diff --git a/src/main/kotlin/shop/itbug/fluttercheckversionx/document/YamlDocument.kt b/src/main/kotlin/shop/itbug/fluttercheckversionx/document/YamlDocument.kt index fc7aad81..57795797 100644 --- a/src/main/kotlin/shop/itbug/fluttercheckversionx/document/YamlDocument.kt +++ b/src/main/kotlin/shop/itbug/fluttercheckversionx/document/YamlDocument.kt @@ -7,9 +7,7 @@ import com.intellij.openapi.editor.Editor import com.intellij.psi.PsiElement import com.intellij.psi.PsiFile import com.intellij.psi.impl.source.tree.LeafPsiElement -import com.intellij.psi.util.elementType import org.jetbrains.yaml.psi.impl.YAMLKeyValueImpl -import org.slf4j.LoggerFactory import shop.itbug.fluttercheckversionx.document.Helper.Companion.addKeyValueSection import shop.itbug.fluttercheckversionx.model.PubVersionDataModel import shop.itbug.fluttercheckversionx.services.PubService @@ -22,9 +20,6 @@ import shop.itbug.fluttercheckversionx.util.isDartPluginElement */ class YamlDocument : DocumentationProvider, ExternalDocumentationProvider { - private val logger = LoggerFactory.getLogger(YamlDocument::class.java) - - /** * 生成插件版本的提示 */ @@ -115,7 +110,6 @@ class YamlDocument : DocumentationProvider, ExternalDocumentationProvider { @Deprecated("Deprecated in Java") override fun hasDocumentationFor(element: PsiElement?, originalElement: PsiElement?): Boolean { - logger.info("hasDocumentationFor >> ${element.elementType}") return false } diff --git a/src/main/kotlin/shop/itbug/fluttercheckversionx/dsl/DslUtil.kt b/src/main/kotlin/shop/itbug/fluttercheckversionx/dsl/DslUtil.kt index 2527e991..c94e29d6 100644 --- a/src/main/kotlin/shop/itbug/fluttercheckversionx/dsl/DslUtil.kt +++ b/src/main/kotlin/shop/itbug/fluttercheckversionx/dsl/DslUtil.kt @@ -22,8 +22,11 @@ fun DialogPanel.showCenter(project: Project) { } fun DialogPanel.show(anActionEvent: AnActionEvent) { - JBPopupFactory.getInstance().createComponentPopupBuilder(this,null) - .createPopup().show(RelativePoint(anActionEvent.inputEvent.component.locationOnScreen)) + anActionEvent.inputEvent?.let { + JBPopupFactory.getInstance().createComponentPopupBuilder(this,null) + .createPopup().show(RelativePoint(it.component.locationOnScreen)) + } + } /** diff --git a/src/main/kotlin/shop/itbug/fluttercheckversionx/dsl/RequestItemLayout.kt b/src/main/kotlin/shop/itbug/fluttercheckversionx/dsl/RequestItemLayout.kt index 052ca746..4ebe53af 100644 --- a/src/main/kotlin/shop/itbug/fluttercheckversionx/dsl/RequestItemLayout.kt +++ b/src/main/kotlin/shop/itbug/fluttercheckversionx/dsl/RequestItemLayout.kt @@ -10,7 +10,7 @@ import java.net.URI import javax.swing.BorderFactory -fun String.formatUrl(setting: DioxListeningSetting): String{ +fun String.formatUrl(setting: DioxListeningSetting): String { if(setting.showHost.not()){ return URI(this).path } @@ -33,7 +33,7 @@ fun requestDetailLayout(request: Request, isSelected: Boolean,setting: DioxListe label(request.statusCode!!.toString()) .visible(setting.showStatusCode).component.apply { font = JBFont.small() - foreground = if(request.statusCode == 200) UIUtil.getLabelInfoForeground() else color + foreground = if(request.statusCode == 200) UIUtil.getLabelInfoForeground() else UIUtil.getErrorForeground() } label(request.method!!).visible(setting.showMethod).component.apply { font = JBFont.small() diff --git a/src/main/kotlin/shop/itbug/fluttercheckversionx/dsl/SettingPanel.kt b/src/main/kotlin/shop/itbug/fluttercheckversionx/dsl/SettingPanel.kt index a1c97854..563da8ec 100644 --- a/src/main/kotlin/shop/itbug/fluttercheckversionx/dsl/SettingPanel.kt +++ b/src/main/kotlin/shop/itbug/fluttercheckversionx/dsl/SettingPanel.kt @@ -27,9 +27,8 @@ fun settingPanel( ): DialogPanel { val alarm = Alarm(parentDisposable) - lateinit var myPanel: DialogPanel - myPanel = panel { + val myPanel: DialogPanel = panel { row { button(PluginBundle.get("window.chat.loginDialog.text")) { @@ -42,7 +41,7 @@ fun settingPanel( row(PluginBundle.get("setting.language")) { - segmentedButton(listOf("System", "中文", "English")) { it }.bind(object : + segmentedButton(listOf("System", "中文", "繁體", "English","한국어","日本語")) { it }.bind(object : ObservableMutableProperty { override fun set(value: String) { model.lang = value @@ -51,23 +50,20 @@ fun settingPanel( override fun afterChange(listener: (String) -> Unit) { } - override fun afterChange(listener: (String) -> Unit, parentDisposable: Disposable) { - } - override fun get(): String { return model.lang } }) } - //.comment(PluginBundle.get("setting.reset.tip")) + .comment(PluginBundle.get("setting.reset.tip")) } - group("Diox") { - row("Diox ${PluginBundle.get("setting.listening.port")}") { + group("Dio") { + row("Dio ${PluginBundle.get("setting.listening.port")}") { textField().bindText(model::serverPort) - } + }.comment(PluginBundle.get("setting.reset.tip")) // 新接口弹出提醒 @@ -104,15 +100,12 @@ fun settingPanel( row(PluginBundle.get("ass.1")) { textField().bindText(model::assetCompilationTriggerString) } - //.comment(PluginBundle.get("ass.2")) row(PluginBundle.get("ass.3")) { intTextField().bindIntText(model::assetCompilationTriggerLen) } - //.comment(PluginBundle.get("ass.4")) row(PluginBundle.get("ass.5")) { textField().bindText(model::assetScanFolderName) } - //.comment(PluginBundle.get("ass.6")) } } diff --git a/src/main/kotlin/shop/itbug/fluttercheckversionx/form/components/ApiListPanel.kt b/src/main/kotlin/shop/itbug/fluttercheckversionx/form/components/ApiListPanel.kt index 30dfdf09..a2a6655b 100644 --- a/src/main/kotlin/shop/itbug/fluttercheckversionx/form/components/ApiListPanel.kt +++ b/src/main/kotlin/shop/itbug/fluttercheckversionx/form/components/ApiListPanel.kt @@ -85,7 +85,7 @@ class ApiListPanel(val project: Project) : JBList(), ListSelectionListe private val myDataContext: AsyncDataContext = object : AsyncDataContext { override fun getData(dataId: String): Any? { - if (dataId == SELECT_KEY) { + if (dataId == "select-api") { return this@ApiListPanel.selectedValue } else if (dataId == PROJECT_KEY) { return project diff --git a/src/main/kotlin/shop/itbug/fluttercheckversionx/form/components/RightDetailPanel.kt b/src/main/kotlin/shop/itbug/fluttercheckversionx/form/components/RightDetailPanel.kt index 4e2822cc..b79c5443 100644 --- a/src/main/kotlin/shop/itbug/fluttercheckversionx/form/components/RightDetailPanel.kt +++ b/src/main/kotlin/shop/itbug/fluttercheckversionx/form/components/RightDetailPanel.kt @@ -44,7 +44,7 @@ class RightDetailPanel(val project: Project) : JPanel(BorderLayout()) { init { border = BorderFactory.createEmptyBorder() jsonViewInit() - add(actionsToolBar, BorderLayout.NORTH) + add(actionsToolBar(), BorderLayout.NORTH) FlutterApiClickBus.listening { changeShowValue(it) } @@ -70,18 +70,18 @@ class RightDetailPanel(val project: Project) : JPanel(BorderLayout()) { jsonView.changeValue("") } - private val actionsToolBar: JComponent - get() { - val toolbar = DefaultActionGroup(*createAnActions).createWithToolbar("Request Json Toolbar") + private fun actionsToolBar() : JComponent + { + val toolbar = DefaultActionGroup(*createAnActions()).createWithToolbar("Request Json Toolbar") toolbar.targetComponent = this return toolbar.component } - private val createAnActions - get() : Array { + private fun createAnActions() : Array { return arrayOf( MyActionButton(jsonToFreezedModelAction).action, - WidgetUtil.getCopyAnAction(jsonView.text) + WidgetUtil.getCopyAnAction(jsonView.text), + WidgetUtil.getDiscordAction() ) } diff --git a/src/main/kotlin/shop/itbug/fluttercheckversionx/form/socket/SocketRequestForm.kt b/src/main/kotlin/shop/itbug/fluttercheckversionx/form/socket/SocketRequestForm.kt index 2e6cf610..c4b75327 100644 --- a/src/main/kotlin/shop/itbug/fluttercheckversionx/form/socket/SocketRequestForm.kt +++ b/src/main/kotlin/shop/itbug/fluttercheckversionx/form/socket/SocketRequestForm.kt @@ -42,8 +42,6 @@ class SocketRequestForm(val project: Project, private val toolWindow: ToolWindow private val apiListWrapper = JBScrollPane(apiList) -// private val apiWindowStatusText = ApiListStatusBar() - //右侧面板 private val rightFirstPanel = RightDetailPanel(project) private val myRightComponent = JPanel(CardLayout()).apply { @@ -98,7 +96,6 @@ class SocketRequestForm(val project: Project, private val toolWindow: ToolWindow SocketMessageBus.listening { autoScrollToMax() } -// addToBottom(apiWindowStatusText) } diff --git a/src/main/kotlin/shop/itbug/fluttercheckversionx/i18n/DynamicPluginBundle.kt b/src/main/kotlin/shop/itbug/fluttercheckversionx/i18n/DynamicPluginBundle.kt index 3d0735e9..ccfa0f21 100644 --- a/src/main/kotlin/shop/itbug/fluttercheckversionx/i18n/DynamicPluginBundle.kt +++ b/src/main/kotlin/shop/itbug/fluttercheckversionx/i18n/DynamicPluginBundle.kt @@ -1,34 +1,63 @@ package shop.itbug.fluttercheckversionx.i18n import com.intellij.AbstractBundle -import com.intellij.lang.LangBundle import shop.itbug.fluttercheckversionx.services.PluginStateService import java.lang.invoke.MethodHandles import java.lang.reflect.Method import java.util.* ///抽象类,支持加载与安装的语言包匹配的本地化消息。 -open class DynamicPluginBundle(pathToBundle: String): AbstractBundle(pathToBundle) { +open class DynamicPluginBundle(pathToBundle: String) : AbstractBundle(pathToBundle) { override fun findBundle( pathToBundle: String, loader: ClassLoader, control: ResourceBundle.Control ): ResourceBundle { val base = super.findBundle(pathToBundle, loader, control) - val ideLocale = LangBundle.getLocale() + val ideLocale = Locale.getDefault().language val settingLang = PluginStateService.getInstance().state?.lang ?: "" - println("语言: $settingLang $base") - if(settingLang != "中文"){ - val localizedPath = pathToBundle + "_"+ideLocale.language - println("localized path is $localizedPath") - val localBundle = super.findBundle(localizedPath, DynamicPluginBundle::class.java.classLoader, control) - if(base != localBundle){ - setParent(localBundle,base) - return localBundle + val localizedPath = when (settingLang) { + "English" -> { + pathToBundle + "_en" + } + + "繁體" -> { + pathToBundle + "_hk" + } + + "中文" -> { + pathToBundle + } + + "한국어" -> { + pathToBundle + "_ko" + } + + "日本語" -> { + pathToBundle + "_ja" + } + + else -> { + when (ideLocale) { + "en" -> pathToBundle + "_en" + "ja" -> pathToBundle + "_ja" + "hk" -> pathToBundle + "_hk" + "ko" -> pathToBundle + "_ko" + else -> { + pathToBundle + } + } } } + + val localBundle = super.findBundle(localizedPath, DynamicPluginBundle::class.java.classLoader, control) + if (base != localBundle) { + setParent(localBundle, base) + return localBundle + } return base } + /** * 从com.intellij中借用代码。DynamicBundle使用反射设置父捆绑包。 */ diff --git a/src/main/kotlin/shop/itbug/fluttercheckversionx/icons/MyIcons.kt b/src/main/kotlin/shop/itbug/fluttercheckversionx/icons/MyIcons.kt index b9c0f997..ac9fb6c7 100644 --- a/src/main/kotlin/shop/itbug/fluttercheckversionx/icons/MyIcons.kt +++ b/src/main/kotlin/shop/itbug/fluttercheckversionx/icons/MyIcons.kt @@ -27,6 +27,8 @@ object MyIcons { //收藏图标(选中) var openai = IconLoader.getIcon("/icons/openai.svg",MyIcons::class.java) + + val discord = IconLoader.getIcon("/icons/discord.svg",MyIcons::class.java) } diff --git a/src/main/kotlin/shop/itbug/fluttercheckversionx/inlay/HintsInlayPresentationFactory.kt b/src/main/kotlin/shop/itbug/fluttercheckversionx/inlay/HintsInlayPresentationFactory.kt index 8b793728..e30934fe 100644 --- a/src/main/kotlin/shop/itbug/fluttercheckversionx/inlay/HintsInlayPresentationFactory.kt +++ b/src/main/kotlin/shop/itbug/fluttercheckversionx/inlay/HintsInlayPresentationFactory.kt @@ -48,29 +48,60 @@ fun Editor.getIndent(element: PsiElement): Int { class HintsInlayPresentationFactory(private val factory: PresentationFactory) { - fun lineStart(editor: Editor,element: PsiElement): InlayPresentation { + + fun blockIconAndText(editor: Editor, element: PsiElement, icon: Icon, text: String): InlayPresentation { + val lWidth = lineStart(editor, element) + val iText = iconText(icon, text) + return factory.seq(lWidth, iText) + } + + fun blockText(editor: Editor, element: PsiElement, text: String): InlayPresentation { + val w = lineStart(editor, element) + return factory.seq(w, factory.smallText(text).addRoundBg()) + } + + private fun lineStart(editor: Editor, element: PsiElement): InlayPresentation { val indent = editor.getIndent(element) val indentText = StringUtil.repeat("\t\t", indent) return factory.text(indentText) } - fun iconText(icon: Icon,text: String) : InlayPresentation { - return factory.seq(factory.smallScaledIcon(icon),factory.smallText(text)).addRoundBg() + + fun iconRoundClick(icon: Icon,clicked: InlayPresentationClickHandle? = null): InlayPresentation { + return factory.smallScaledIcon(icon).addRoundBg().clickHandle(clicked) } - fun lineStartText(editor: Editor,element: PsiElement,text: String) : InlayPresentation { - return factory.seq(lineStart(editor, element),factory.smallText(text).addRoundBg()) + /** + * 图标+文字 + * @param iconIsInLeft 图标是否在左边,false: 图标在右边 + */ + fun iconText( + icon: Icon, + text: String, + iconIsInLeft: Boolean = true, + handle: InlayPresentationClickHandle? = null + ): InlayPresentation { + val iconInlay = factory.smallScaledIcon(icon) + return if (iconIsInLeft) { + factory.seq(iconInlay, factory.smallText(text)).addRoundBg().clickHandle(handle) + } else { + factory.seq(factory.smallText(text), iconInlay).addRoundBg().clickHandle(handle) + } + } + + fun lineStartText(editor: Editor, element: PsiElement, text: String): InlayPresentation { + return factory.seq(lineStart(editor, element), factory.smallText(text).addRoundBg()) } - fun InlayPresentation.addRoundBg() : InlayPresentation { + private fun InlayPresentation.addRoundBg(): InlayPresentation { return factory.roundWithBackgroundAndSmallInset(this) } - private fun InlayPresentation.clickHandle(handle: InlayPresentationClickHandle?) : InlayPresentation { - return factory.mouseHandling(this, clickListener = handle,null) + private fun InlayPresentation.clickHandle(handle: InlayPresentationClickHandle?): InlayPresentation { + return factory.mouseHandling(this, clickListener = handle, null) } - fun simpleText(text: String, tip: String?,handle: InlayPresentationClickHandle?): InlayPresentation { + fun simpleText(text: String, tip: String?, handle: InlayPresentationClickHandle?): InlayPresentation { return text(text).bg().addTip(tip ?: text).clickHandle(handle) } @@ -124,21 +155,19 @@ class HintsInlayPresentationFactory(private val factory: PresentationFactory) { ) - - private fun pluginMenusActionPopup(itemSelected: (key: String) -> Unit): BaseListPopupStep = MyPluginMenusAvtionPopup(actionMenus, itemSelected) - fun getImageWithPath(path: String,basePath: String) : InlayPresentation? { - return try{ - if(!File(path).exists()){ - return null + fun getImageWithPath(path: String, basePath: String): InlayPresentation? { + return try { + if (!File(path).exists()) { + return null } - val i = ImageIcon(path).image.getScaledInstance(16,16, Image.SCALE_SMOOTH) - val imageIcon : Icon = ImageIcon(i) + val i = ImageIcon(path).image.getScaledInstance(16, 16, Image.SCALE_SMOOTH) + val imageIcon: Icon = ImageIcon(i) return factory.icon(imageIcon).addTip(basePath) - }catch (e:Exception){ + } catch (e: Exception) { println("$path 读取图片失败:$e") null } diff --git a/src/main/kotlin/shop/itbug/fluttercheckversionx/inlay/dartfile/DartTypeInlayHintsProvider.kt b/src/main/kotlin/shop/itbug/fluttercheckversionx/inlay/dartfile/DartTypeInlayHintsProvider.kt index 5e0345d5..b30cc8d1 100644 --- a/src/main/kotlin/shop/itbug/fluttercheckversionx/inlay/dartfile/DartTypeInlayHintsProvider.kt +++ b/src/main/kotlin/shop/itbug/fluttercheckversionx/inlay/dartfile/DartTypeInlayHintsProvider.kt @@ -4,10 +4,11 @@ import com.intellij.codeInsight.hints.* import com.intellij.openapi.editor.Editor import com.intellij.psi.PsiElement import com.intellij.psi.PsiFile -import com.intellij.psi.impl.source.tree.LeafPsiElement import com.intellij.refactoring.suggested.endOffset import com.jetbrains.lang.dart.analyzer.DartAnalysisServerService -import com.jetbrains.lang.dart.psi.impl.* +import com.jetbrains.lang.dart.psi.impl.DartComponentNameImpl +import com.jetbrains.lang.dart.psi.impl.DartVarAccessDeclarationImpl +import com.jetbrains.lang.dart.psi.impl.DartVarDeclarationListImpl import shop.itbug.fluttercheckversionx.config.GenerateAssetsClassConfig import shop.itbug.fluttercheckversionx.config.GenerateAssetsClassConfigModel import shop.itbug.fluttercheckversionx.inlay.HintsInlayPresentationFactory @@ -15,7 +16,6 @@ import shop.itbug.fluttercheckversionx.inlay.json.DefaulImmediateConfigurable import java.awt.Toolkit import java.awt.datatransfer.Clipboard import java.awt.datatransfer.StringSelection -import java.io.File class DartTypeInlayHintsProvider : InlayHintsProvider { @@ -52,6 +52,7 @@ class DartTypeInlayHintsProvider : InlayHintsProvider()[0] filterIsInstance.parent.nextSibling ?: return true + val analysisGethover = DartAnalysisServerService.getInstance(file.project) .analysis_getHover(file.virtualFile, filterIsInstance.textOffset) if (analysisGethover.isNotEmpty()) { @@ -61,7 +62,7 @@ class DartTypeInlayHintsProvider : InlayHintsProvider val ss = StringSelection(staticType) - val clipboard: Clipboard = Toolkit.getDefaultToolkit().getSystemClipboard() + val clipboard: Clipboard = Toolkit.getDefaultToolkit().systemClipboard clipboard.setContents(ss, null) } sink.addInlineElement( @@ -72,94 +73,29 @@ class DartTypeInlayHintsProvider : InlayHintsProvider() - if (children.isNotEmpty()) { - val args = children[0].children.filterIsInstance() /// 参数列表 - for (arg in args) { - if (arg.firstChild.text == "message") { - val docMessage = - (arg.lastChild as DartStringLiteralExpressionImpl).canonicalText.replace( - "\"", - "" - ).replace("\'", "") - val semicolonElement = element.parent.nextSibling; - if (semicolonElement is LeafPsiElement) { - sink.addInlineElement( - semicolonElement.endOffset, - false, - hintsInlayPresentationFactory.simpleText(docMessage, "") { _, _ -> - println("被点击了...") - }, - false - ) - - } - } - } - } - - } - } - } - - } - //资产图片的展示 - if (element.lastChild is DartReferenceExpressionImpl && settings.showImageIconInEditor) { - element.reference?.let { - val referenceValElement = it.resolve()?.parent?.parent - if (referenceValElement is DartVarDeclarationListImpl && referenceValElement.lastChild is DartVarInitImpl) { - val varInitElement = referenceValElement.lastChild - if (varInitElement.lastChild is DartStringLiteralExpressionImpl) { - val path = varInitElement.lastChild.text.replace("'", "").replace("\"", "") - hintsInlayPresentationFactory.getImageWithPath(file.project.basePath + File.separator + path,path) - ?.let { it1 -> sink.addInlineElement(element.endOffset, false, it1, false) } - } - } - } - - -// editor.inlayModel.addBlockElement( -// EditorUtil.getPlainSpaceWidth(editor), -// false, -// true, -// 1, -// object : EditorCustomElementRenderer { -// override fun calcWidthInPixels(inlay: Inlay<*>): Int { -// val lineNumber = editor.document.getLineNumber(element.startOffset) -// val lineStartOffset = editor.document.getLineStartOffset(lineNumber) -// val lineEndOffset = editor.document.getLineEndOffset(lineNumber) -// return lineEndOffset - lineStartOffset -// } -// -// override fun paint( -// inlay: Inlay<*>, -// g: Graphics2D, -// targetRegion: Rectangle2D, -// textAttributes: TextAttributes -// ) { -// g.drawString("hello world!",targetRegion.x.toFloat(),targetRegion.y.toFloat()) -// super.paint(inlay, g, targetRegion, textAttributes) +// if (element.lastChild is DartReferenceExpressionImpl && settings.showImageIconInEditor) { +// element.reference?.let { +// val referenceValElement = it.resolve()?.parent?.parent +// if (referenceValElement is DartVarDeclarationListImpl && referenceValElement.lastChild is DartVarInitImpl) { +// val varInitElement = referenceValElement.lastChild +// if (varInitElement.lastChild is DartStringLiteralExpressionImpl) { +// val path = varInitElement.lastChild.text.replace("'", "").replace("\"", "") +// hintsInlayPresentationFactory.getImageWithPath(file.project.basePath + File.separator + path,path) +// ?.let { it1 -> sink.addInlineElement(element.endOffset, false, it1, false) } // } // } -// ) - } +// } +// +// } - if(element is DartStringLiteralExpressionImpl) { - val path = element.text.replace("'", "").replace("\"", "") - hintsInlayPresentationFactory.getImageWithPath(file.project.basePath + File.separator + path,path) - ?.let { it1 -> sink.addInlineElement(element.endOffset, false, it1, false) } - } +// if(element is DartStringLiteralExpressionImpl) { +// val path = element.text.replace("'", "").replace("\"", "") +// hintsInlayPresentationFactory.getImageWithPath(file.project.basePath + File.separator + path,path) +// ?.let { it1 -> sink.addInlineElement(element.endOffset, false, it1, false) } +// } return true } diff --git a/src/main/kotlin/shop/itbug/fluttercheckversionx/inlay/freezed/FreezedInlay.kt b/src/main/kotlin/shop/itbug/fluttercheckversionx/inlay/freezed/FreezedInlay.kt new file mode 100644 index 00000000..751bf82d --- /dev/null +++ b/src/main/kotlin/shop/itbug/fluttercheckversionx/inlay/freezed/FreezedInlay.kt @@ -0,0 +1,197 @@ +package shop.itbug.fluttercheckversionx.inlay.freezed + +import com.intellij.codeInsight.hints.* +import com.intellij.icons.AllIcons +import com.intellij.openapi.actionSystem.ActionUpdateThread +import com.intellij.openapi.actionSystem.AnActionEvent +import com.intellij.openapi.actionSystem.DataContext +import com.intellij.openapi.actionSystem.DefaultActionGroup +import com.intellij.openapi.editor.Editor +import com.intellij.openapi.ui.popup.JBPopupFactory +import com.intellij.psi.PsiElement +import com.intellij.psi.PsiFile +import com.intellij.refactoring.suggested.endOffset +import com.intellij.ui.awt.RelativePoint +import com.intellij.ui.dsl.builder.panel +import com.jetbrains.lang.dart.psi.impl.DartClassDefinitionImpl +import com.jetbrains.lang.dart.psi.impl.DartFactoryConstructorDeclarationImpl +import org.jetbrains.plugins.terminal.TerminalToolWindowManager +import shop.itbug.fluttercheckversionx.common.MyAction +import shop.itbug.fluttercheckversionx.dialog.JsonToFreezedInputDialog +import shop.itbug.fluttercheckversionx.inlay.HintsInlayPresentationFactory +import shop.itbug.fluttercheckversionx.manager.DartClassManager +import shop.itbug.fluttercheckversionx.util.dart.DartClassUtil +import shop.itbug.fluttercheckversionx.util.exByModifyAllPsiElementText +import shop.itbug.fluttercheckversionx.util.toast +import shop.itbug.fluttercheckversionx.widget.WidgetUtil +import java.awt.event.MouseEvent +import javax.swing.JComponent + + +data class FreezedInlaySetting(var show: Boolean) + +class FreezedInlay : InlayHintsProvider { + override val key: SettingsKey + get() = SettingsKey("freezed inlay") + override val name: String + get() = "FreezedInlay" + override val previewText: String + get() = "@freezed" + + "class Test {}" + + override fun createSettings(): FreezedInlaySetting { + return FreezedInlaySetting(true) + } + + override fun getCollectorFor( + file: PsiFile, + editor: Editor, + settings: FreezedInlaySetting, + sink: InlayHintsSink + ): InlayHintsCollector { + return FreezedInlayCollector(editor) + } + + override fun createConfigurable(settings: FreezedInlaySetting): ImmediateConfigurable { + return FreezedInlayPanel() + } + +} + + +class FreezedInlayCollector(val edit: Editor) : FactoryInlayHintsCollector(edit) { + + private val inlayFactory = HintsInlayPresentationFactory(factory) + override fun collect(element: PsiElement, editor: Editor, sink: InlayHintsSink): Boolean { + + val isFreezedClass = + DartClassUtil.hasMetadata(element, "freezed") || DartClassUtil.hasMetadata(element, "Freezed") + if (isFreezedClass) { +// val lineStart = editor.getLineStart(element) +// val inlayPresentation = +// inlayFactory.iconText(AllIcons.General.ChevronDown, "Freezed Actions ", false) { mouseEvent, point -> +// showFreezedActionMenu(mouseEvent, point, element) +// } +// sink.addBlockElement(lineStart, true, true, 0, inlayPresentation) + val manager = DartClassManager(psiElement = element as DartClassDefinitionImpl) + val freezedElement = manager.findMataDataByText("freezed") ?: manager.findMataDataByText("Freezed") + freezedElement?.let { + sink.addInlineElement( + it.endOffset, + true, + inlayFactory.iconRoundClick(AllIcons.General.ChevronDown) { mouseEvent, _ -> + showFreezedActionMenu( + mouseEvent, + element + ) + }, + true + ) + } + + + } + return true + } + + //显示操作菜单 + private fun showFreezedActionMenu(mouseEvent: MouseEvent, psiElement: PsiElement) { + + + val popupCreate = JBPopupFactory.getInstance().createActionGroupPopup( + "Freezed Actions", createFreezedActionGroup(psiElement, mouseEvent), DataContext.EMPTY_CONTEXT, + JBPopupFactory.ActionSelectionAid.MNEMONICS, true + ) + popupCreate.show(RelativePoint.fromScreen(mouseEvent.locationOnScreen)) + } + + //操作列表 + private fun createFreezedActionGroup(psiElement: PsiElement, mouseEvent: MouseEvent): DefaultActionGroup { + val dartClassElement = psiElement as DartClassDefinitionImpl + val className = dartClassElement.componentName.name ?: "" + val dartClassManager = DartClassManager(className, dartClassElement) + return DefaultActionGroup().apply { + add(object : MyAction({ "Rename" }) { + override fun actionPerformed(e: AnActionEvent) { + + WidgetUtil.getTextEditorPopup( + "Enter a new Class Name", + className, + { it.show(RelativePoint.fromScreen(mouseEvent.locationOnScreen)) }) { + dartClassElement.exByModifyAllPsiElementText(it, className) + dartClassElement.exByModifyAllPsiElementText("_$$it", "_$$className") + dartClassElement.exByModifyAllPsiElementText("_$it", "_$className") + dartClassElement.exByModifyAllPsiElementText("_$$it" + "FromJson", "_$$className" + "FromJson") + } + + } + }) + + + + add(object : MyAction({ "Create FromJson Function" }) { + override fun actionPerformed(e: AnActionEvent) { + dartClassManager.addFreezedFromJsonConstructor(ifExists = { + val fromJsonEle = (it as DartFactoryConstructorDeclarationImpl).componentNameList[1] + dartClassManager.showHints(edit, fromJsonEle, "Already exists") + }) + } + }) + add(object : MyAction({ "Add HiveField annotation" }) { + override fun actionPerformed(e: AnActionEvent) { + e.project?.toast("This feature will be released in version 3.6.0") + } + + override fun update(e: AnActionEvent) { + e.presentation.isEnabled = false + super.update(e) + } + + override fun getActionUpdateThread(): ActionUpdateThread { + return ActionUpdateThread.BGT + } + }) + + addSeparator() + + add(object : MyAction({ "Add .freezed part" }) { + override fun actionPerformed(e: AnActionEvent) { + dartClassManager.addPartForSuffix("freezed") { + dartClassManager.showHints(edit, it, "Already exists") + } + } + }) + + add(object : MyAction({ "Add .g part" }) { + override fun actionPerformed(e: AnActionEvent) { + dartClassManager.addPartForSuffix("g") { + dartClassManager.showHints(edit, it, "Already exists") + } + } + }) + + addSeparator() + + add(object : MyAction({ "Json to Freezed" }) { + override fun actionPerformed(e: AnActionEvent) { + JsonToFreezedInputDialog(psiElement.project).show() + } + }) + add(object : MyAction({ "Run build runner" }) { + override fun actionPerformed(e: AnActionEvent) { + TerminalToolWindowManager.getInstance(psiElement.project) + .createLocalShellWidget(psiElement.project.basePath, "FlutterCheckVersionX") + .executeCommand("flutter pub run build_runner build") + } + }) + + } + } +} + +class FreezedInlayPanel : ImmediateConfigurable { + override fun createComponent(listener: ChangeListener): JComponent { + return panel { } + } + +} \ No newline at end of file diff --git a/src/main/kotlin/shop/itbug/fluttercheckversionx/manager/DartClassManager.kt b/src/main/kotlin/shop/itbug/fluttercheckversionx/manager/DartClassManager.kt new file mode 100644 index 00000000..8d371028 --- /dev/null +++ b/src/main/kotlin/shop/itbug/fluttercheckversionx/manager/DartClassManager.kt @@ -0,0 +1,175 @@ +package shop.itbug.fluttercheckversionx.manager + +import com.intellij.openapi.actionSystem.AnActionEvent +import com.intellij.openapi.actionSystem.DataContext +import com.intellij.openapi.actionSystem.DefaultActionGroup +import com.intellij.openapi.command.WriteCommandAction +import com.intellij.openapi.editor.Editor +import com.intellij.openapi.ui.popup.Balloon +import com.intellij.openapi.ui.popup.JBPopupFactory +import com.intellij.psi.PsiElement +import com.intellij.psi.util.PsiTreeUtil +import com.intellij.ui.components.JBLabel +import com.jetbrains.lang.dart.psi.impl.DartClassDefinitionImpl +import com.jetbrains.lang.dart.psi.impl.DartFactoryConstructorDeclarationImpl +import com.jetbrains.lang.dart.psi.impl.DartImportStatementImpl +import com.jetbrains.lang.dart.psi.impl.DartMetadataImpl +import shop.itbug.fluttercheckversionx.common.MyDumbAwareAction +import shop.itbug.fluttercheckversionx.util.* + + +typealias IfExistsFun = (element: PsiElement) -> Unit + +/** + * 对dart类的一些操作函数 + */ +class DartClassManager(val className: String, private val psiElement: DartClassDefinitionImpl) { + + + constructor(psiElement: DartClassDefinitionImpl) : this( + className = psiElement.componentName.name ?: "", + psiElement = psiElement + ) + + + /** + * 初始化freezed 虚拟文件 + */ + private val psiFile = MyDartPsiElementUtil.genFreezedClass( + project = psiElement.project, + className = className, + addConstructor = false, + addFromJson = true, + properties = "String? text" + ) + + private val project = psiElement.project + + /** + * 添加freezed fromJson函数 + */ + fun addFreezedFromJsonConstructor(ifExists: IfExistsFun? = null) { + val findFromJsonElement = + findTypesByPsiElement().find { it.componentName?.text == "fromJson" } + if (findFromJsonElement != null) { + ifExists?.invoke(findFromJsonElement) + return + } + psiElement.classBody?.classMembers?.let { + findFromJsonTextByPsiFile()?.apply { + WriteCommandAction.runWriteCommandAction(psiElement.project) { + psiElement.classBody?.classMembers?.add(this) + psiElement.reformatText() + } + } + } + } + + /** + * 查找生成的列表 + */ + private fun findTypeList(clazz: Class): Collection { + return PsiTreeUtil.findChildrenOfType(psiFile, clazz) + } + + /** + * 查找fromJson函数 + */ + private fun findFromJsonTextByPsiFile(): DartFactoryConstructorDeclarationImpl? { + val children = findTypeList(DartFactoryConstructorDeclarationImpl::class.java) + if (children.size > 1) { + return children.find { it.componentName?.text == "fromJson" } + } + return null + } + + + /** + * 查找所有T类型的psi节点 + */ + private inline fun findTypesByPsiElement(): List { + val list: List = MyPsiElementUtil.findAllMatchingElements(psiElement) { _, p -> + return@findAllMatchingElements p is T + } + return list.filterIsInstance() + } + + + fun showHints(edit: Editor, psiElement: PsiElement, text: String) { + val relative = psiElement.getRelativePoint(edit) + JBPopupFactory.getInstance().createBalloonBuilder(JBLabel(text)).createBalloon() + .show(relative, Balloon.Position.above) + } + + /** + * 查找mata data psi 节点 + */ + fun findMataDataByText(text: String): DartMetadataImpl? { + return findTypesByPsiElement().find { it.referenceExpression.text == text } + } + + /** + * 添加part语句 + */ + fun addPartForSuffix(suffix: String, ifExists: IfExistsFun? = null) { + val fileName = psiElement.getFileName() + val part = MyDartPsiElementUtil.createDartPart("part '$fileName.$suffix.dart';", psiElement.project) + if (part != null) { + + //判断是否存在,如果存在就不要重复添加了 + psiElement.containingFile.findPsiElementByText(part.text)?.apply { + ifExists?.invoke(this) + return + } + + val importStatement = + PsiTreeUtil.findChildrenOfType(psiElement.containingFile, DartImportStatementImpl::class.java) + if (importStatement.isNotEmpty()) { + WriteCommandAction.runWriteCommandAction(psiElement.project) { + importStatement.last().apply { + addAfter(part, this.lastChild) + psiElement.containingFile.reformatText() + } + } + } else { + psiElement.containingFile.firstChild.apply { + this.runWriteCommandAction { + addBefore(part, this.lastChild) + psiElement.containingFile.reformatText() + } + } + } + + } else { + psiElement.project.toastWithError("add Failed!") + } + } + + + /** + * //Todo v1.6.0 自动添加Hive注解 + **/ + fun generateHiveMate() { + val constructor = findTypesByPsiElement().filter { + val manager = it.manager() + return@filter manager.hasProperties() && manager.hasHiveMate().not() + } + if (constructor.isNotEmpty()) { + val popup = JBPopupFactory.getInstance().createActionGroupPopup( + "Choose One", DefaultActionGroup().apply { + constructor.forEach { ele -> + val name = ele.componentNameList.joinToString(".") { it.text } + add(object : MyDumbAwareAction({ name }) { + override fun actionPerformed(e: AnActionEvent) { + + } + }) + } + }, + DataContext.EMPTY_CONTEXT, JBPopupFactory.ActionSelectionAid.MNEMONICS, true + ) + popup.showCenteredInCurrentWindow(project) + } + } + +} diff --git a/src/main/kotlin/shop/itbug/fluttercheckversionx/manager/DartFactoryConstructorDeclarationImplManager.kt b/src/main/kotlin/shop/itbug/fluttercheckversionx/manager/DartFactoryConstructorDeclarationImplManager.kt new file mode 100644 index 00000000..74eca5ab --- /dev/null +++ b/src/main/kotlin/shop/itbug/fluttercheckversionx/manager/DartFactoryConstructorDeclarationImplManager.kt @@ -0,0 +1,79 @@ +package shop.itbug.fluttercheckversionx.manager + +import com.jetbrains.lang.dart.psi.DartDefaultFormalNamedParameter +import com.jetbrains.lang.dart.psi.DartMetadata +import com.jetbrains.lang.dart.psi.DartNormalFormalParameter +import com.jetbrains.lang.dart.psi.impl.DartFactoryConstructorDeclarationImpl + +/** + * 封装自己的属性节点 + * @param option 是否在必填参数中, true 表示可选则在 {} 中 + */ +data class ConstructorProperties( + val name: String, + val index: Int, + val dartDefaultFormalNamedParameter: DartDefaultFormalNamedParameter? = null, + val dartNormalFormalParameter: DartNormalFormalParameter? = null, + val dataMetadataList: List = emptyList(), + val option: Boolean +) + +/** + * 构造函数的相关操作 + */ +class DartFactoryConstructorDeclarationImplManager(val psiElement: DartFactoryConstructorDeclarationImpl) { + + + /** + * 是否有参数 + */ + fun hasProperties(): Boolean { + return psiElement.formalParameterList != null + } + + + /** + * 是否有HiveType注解 + */ + fun hasHiveMate() = psiElement.getMetadataByName("HiveType") != null + + + /** + * 封装为自己的 + * 获取构造函数的所有参数 + */ + fun getAllProperties(): List { + val result = mutableListOf() + val normalParameters = psiElement.formalParameterList?.normalFormalParameterList ?: emptyList() + val defaultFormalParameters = + psiElement.formalParameterList?.optionalFormalParameters?.defaultFormalNamedParameterList ?: emptyList() + + normalParameters.forEachIndexed { index, it -> + + result.add( + ConstructorProperties( + name = it.simpleFormalParameter?.componentName?.text ?: "", + index = index, + option = false, + dartNormalFormalParameter = it, + dataMetadataList = it.simpleFormalParameter?.metadataList ?: emptyList() + ) + ) + } + + defaultFormalParameters.forEach { + result.add( + ConstructorProperties( + name = it.normalFormalParameter.simpleFormalParameter?.componentName?.text ?: "", + index = result.size + 1, + dartDefaultFormalNamedParameter = it, + option = true, + dataMetadataList = it.normalFormalParameter.simpleFormalParameter?.metadataList ?: emptyList() + ) + ) + + } + + return result + } +} \ No newline at end of file diff --git a/src/main/kotlin/shop/itbug/fluttercheckversionx/request/RequestPanelUi.kt b/src/main/kotlin/shop/itbug/fluttercheckversionx/request/RequestPanelUi.kt new file mode 100644 index 00000000..adb71283 --- /dev/null +++ b/src/main/kotlin/shop/itbug/fluttercheckversionx/request/RequestPanelUi.kt @@ -0,0 +1,76 @@ +package shop.itbug.fluttercheckversionx.request + +import cn.hutool.http.HttpUtil +import com.intellij.execution.filters.TextConsoleBuilderFactory +import com.intellij.execution.ui.ConsoleViewContentType +import com.intellij.openapi.project.Project +import com.intellij.openapi.wm.ToolWindow +import com.intellij.ui.components.JBTextField +import com.intellij.util.ui.components.BorderLayoutPanel +import shop.itbug.fluttercheckversionx.util.toast +import shop.itbug.fluttercheckversionx.util.toastWithError +import java.net.HttpURLConnection +import java.net.URL +import javax.swing.JButton +import javax.swing.JComponent +import javax.swing.JToolBar +import javax.swing.SwingConstants + + +class RequestPanelUi(private val toolWindow: ToolWindow,private val project: Project): BorderLayoutPanel() { + + private val apiInput = JBTextField() + private val generateButton = JButton("Send") + + init { + addToTop(createToolbar()) + generateButton.addActionListener { getApiJson() } + val console = TextConsoleBuilderFactory.getInstance().createBuilder(project).console + console.print("hello", ConsoleViewContentType.SYSTEM_OUTPUT) + } + + ///创建顶部操作区域 + private fun createToolbar(): JComponent { + val toolbar = JToolBar() + toolbar.add(apiInput) + toolbar.add(generateButton) + toolbar.isFloatable = false + toolbar.orientation = SwingConstants.HORIZONTAL + return toolbar + } + + private fun getApiJson() { + val api = apiInput.text + if(validUrl(api)){ + try{ + val response = HttpUtil.get(api) + println(response) + }catch (e:Exception){ + project.toast(e.localizedMessage) + } + }else { + project.toastWithError("Unable to access URL") + } + } + + + private fun validUrl(urlString: String) : Boolean { + try { + val url = URL(urlString) + val connection: HttpURLConnection = url.openConnection() as HttpURLConnection + connection.setRequestMethod("HEAD") + val responseCode: Int = connection.getResponseCode() + return if (responseCode == HttpURLConnection.HTTP_OK) { + println("URL is accessible") + true + } else { + println("URL is not accessible") + false + } + } catch (e: Exception) { + println("Invalid URL") + return false + } + } + +} \ No newline at end of file diff --git a/src/main/kotlin/shop/itbug/fluttercheckversionx/services/FlutterService.kt b/src/main/kotlin/shop/itbug/fluttercheckversionx/services/FlutterService.kt new file mode 100644 index 00000000..4a642d93 --- /dev/null +++ b/src/main/kotlin/shop/itbug/fluttercheckversionx/services/FlutterService.kt @@ -0,0 +1,76 @@ +package shop.itbug.fluttercheckversionx.services + + +import cn.hutool.http.HttpUtil +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable +import kotlinx.serialization.json.Json + +object FlutterService { + fun getVersion() : FlutterVersions? { + return try{ + val url = " https://storage.googleapis.com/flutter_infra_release/releases/releases_macos.json" + val get:String = HttpUtil.get(url) + val json = Json { allowStructuredMapKeys = true } + json.decodeFromString(FlutterVersions.serializer(),get) + }catch (e: Exception){ + null + } + } +} + +// To parse the JSON, install kotlin's serialization plugin and do: +// +// val json = Json { allowStructuredMapKeys = true } +// val flutterVersions = json.parse(FlutterVersions.serializer(), jsonString) + + +@Serializable +data class FlutterVersions ( + @SerialName("base_url") + val baseURL: String, + + @SerialName("current_release") + val currentRelease: CurrentRelease, + + val releases: List +) + +@Serializable +data class CurrentRelease ( + val beta: String, + val dev: String, + val stable: String +) + +@Serializable +data class Release ( + val hash: String, + val channel: Channel, + val version: String, + + @SerialName("dart_sdk_version") + val dartSDKVersion: String? = null, + + @SerialName("dart_sdk_arch") + val dartSDKArch: DartSDKArch? = null, + + @SerialName("release_date") + val releaseDate: String, + + val archive: String, + val sha256: String +) + +@Serializable +enum class Channel(val value: String) { + @SerialName("beta") Beta("beta"), + @SerialName("dev") Dev("dev"), + @SerialName("stable") Stable("stable"); +} + +@Serializable +enum class DartSDKArch(val value: String) { + @SerialName("arm64") Arm64("arm64"), + @SerialName("x64") X64("x64"); +} diff --git a/src/main/kotlin/shop/itbug/fluttercheckversionx/services/MyUserBarFactory.kt b/src/main/kotlin/shop/itbug/fluttercheckversionx/services/MyUserBarFactory.kt index 307cc1c3..16d25c79 100644 --- a/src/main/kotlin/shop/itbug/fluttercheckversionx/services/MyUserBarFactory.kt +++ b/src/main/kotlin/shop/itbug/fluttercheckversionx/services/MyUserBarFactory.kt @@ -1,5 +1,6 @@ package shop.itbug.fluttercheckversionx.services +import com.intellij.ide.BrowserUtil import com.intellij.openapi.project.Project import com.intellij.openapi.ui.popup.JBPopup import com.intellij.openapi.ui.popup.JBPopupFactory @@ -9,7 +10,8 @@ import com.intellij.openapi.wm.StatusBarWidget import com.intellij.openapi.wm.StatusBarWidgetFactory import com.intellij.ui.awt.RelativePoint import com.intellij.ui.components.JBLabel -import org.jetbrains.plugins.terminal.TerminalView +import org.jetbrains.plugins.terminal.TerminalToolWindowManager +import shop.itbug.fluttercheckversionx.constance.discordUrl import shop.itbug.fluttercheckversionx.dialog.JsonToFreezedInputDialog import shop.itbug.fluttercheckversionx.dialog.SearchDialog import shop.itbug.fluttercheckversionx.i18n.PluginBundle @@ -27,7 +29,8 @@ enum class PluginActions(val title: String) { RunBuilder(PluginBundle.get("run.build_runner.build")), FlutterClan(PluginBundle.get("flutter.clean")), FlutterPushPlugin(PluginBundle.get("dart.pub.publish")), - JsonToFreezed("Json to Freezed") + JsonToFreezed("Json to Freezed"), + Discord("Discord") } ///用户面板 @@ -37,7 +40,7 @@ class MyUserBarFactory : StatusBarWidgetFactory { } override fun getDisplayName(): String { - return "典典账号登录" + return "FlutterCheckVersionX" } override fun isAvailable(project: Project): Boolean { @@ -133,18 +136,11 @@ class MyUserAccountBar(var project: Project) : CustomStatusBarWidget { SearchPlugin -> { SearchDialog(project).show() } - -// CheckVersion -> { -// val pubspecFile = MyPsiElementUtil.getPubSecpYamlFile(project) -// pubspecFile?.let { -// val plugins = MyPsiElementUtil.getAllPlugins(project) -// print(plugins) -// } -// } RunBuilder -> runCommand("flutter pub run build_runner build") FlutterClan -> runCommand("flutter clean") FlutterPushPlugin -> runCommand(" dart pub publish") JsonToFreezed -> jsonToFreezedRun() + Discord -> BrowserUtil.browse(discordUrl) } } @@ -158,7 +154,7 @@ class MyUserAccountBar(var project: Project) : CustomStatusBarWidget { } private fun runCommand(code: String) { - TerminalView.getInstance(project).createLocalShellWidget(project.basePath, "FlutterCheckVersionX") + TerminalToolWindowManager.getInstance(project).createLocalShellWidget(project.basePath, "FlutterCheckVersionX") .executeCommand(code) } diff --git a/src/main/kotlin/shop/itbug/fluttercheckversionx/setting/GeneraAssetsSettingPanel.kt b/src/main/kotlin/shop/itbug/fluttercheckversionx/setting/GeneraAssetsSettingPanel.kt index 6d97529e..c28d0afb 100644 --- a/src/main/kotlin/shop/itbug/fluttercheckversionx/setting/GeneraAssetsSettingPanel.kt +++ b/src/main/kotlin/shop/itbug/fluttercheckversionx/setting/GeneraAssetsSettingPanel.kt @@ -12,8 +12,6 @@ import com.intellij.ui.dsl.builder.bindSelected import com.intellij.ui.dsl.builder.bindText import com.intellij.ui.dsl.builder.panel import com.intellij.util.Alarm -import com.intellij.util.ui.JBFont -import com.intellij.util.ui.JBUI import com.intellij.util.ui.components.BorderLayoutPanel import com.intellij.vcs.commit.NonModalCommitPanel.Companion.showAbove import shop.itbug.fluttercheckversionx.config.GenerateAssetsClassConfig @@ -91,12 +89,12 @@ class GeneraAssetsSettingPanel( super.update(e) } - override fun getActionUpdateThread(): ActionUpdateThread { - return ActionUpdateThread.BGT - } }, - WidgetUtil.getHelpAnAction { - WidgetUtil.showTopBalloon(it.inputEvent.component, PluginBundle.get("g.14")) + WidgetUtil.getHelpAnAction { it -> + it.inputEvent?.let { + WidgetUtil.showTopBalloon(it.component, PluginBundle.get("g.14")) + } + }, WidgetUtil.getMoneyAnAction() ) @@ -155,12 +153,6 @@ fun getGeneraAssetsPanel( row(PluginBundle.get("g.10.1")) { checkBox(PluginBundle.get("g.10.2")).bindSelected(settingModel::showImageIconInEditor) } - row { - label(PluginBundle.get("g.11")).component.apply { - font = JBFont.small() - foreground = JBUI.CurrentTheme.Link.Foreground.DISABLED - } - } } val alarm = Alarm(parentDisposable) diff --git a/src/main/kotlin/shop/itbug/fluttercheckversionx/util/MyPsiElementUtil.kt b/src/main/kotlin/shop/itbug/fluttercheckversionx/util/MyPsiElementUtil.kt index 825264cd..85e07e3a 100644 --- a/src/main/kotlin/shop/itbug/fluttercheckversionx/util/MyPsiElementUtil.kt +++ b/src/main/kotlin/shop/itbug/fluttercheckversionx/util/MyPsiElementUtil.kt @@ -299,9 +299,6 @@ class MyDartPsiElementUtil { ) } - fun freezedGetDartFactoryConstructorDeclarationImpl(file: PsiFile): DartFactoryConstructorDeclarationImpl { - return PsiTreeUtil.findChildOfType(file, DartFactoryConstructorDeclarationImpl::class.java)!! - } /** * 生成可空的属性 @@ -351,6 +348,12 @@ class MyDartPsiElementUtil { } + fun createDartPart(text: String,project: Project) : DartPartStatementImpl? { + val createDummyFile = DartElementGenerator.createDummyFile(project, text) + return PsiTreeUtil.getChildOfType(createDummyFile,DartPartStatementImpl::class.java) + } + + } diff --git a/src/main/kotlin/shop/itbug/fluttercheckversionx/util/MyPsiUtil.kt b/src/main/kotlin/shop/itbug/fluttercheckversionx/util/MyPsiUtil.kt index e6fb5627..476b6251 100644 --- a/src/main/kotlin/shop/itbug/fluttercheckversionx/util/MyPsiUtil.kt +++ b/src/main/kotlin/shop/itbug/fluttercheckversionx/util/MyPsiUtil.kt @@ -4,10 +4,7 @@ import com.intellij.openapi.command.WriteCommandAction import com.intellij.openapi.project.Project import com.intellij.openapi.vfs.LocalFileSystem import com.intellij.project.stateStore -import com.intellij.psi.PsiElement -import com.intellij.psi.PsiFile -import com.intellij.psi.PsiFileFactory -import com.intellij.psi.PsiManager +import com.intellij.psi.* import com.intellij.psi.impl.PsiFileFactoryImpl import com.intellij.psi.impl.source.tree.LeafPsiElement import com.intellij.psi.util.PsiTreeUtil @@ -29,7 +26,6 @@ import shop.itbug.fluttercheckversionx.model.FlutterPluginType import java.io.File - /** * PSI 操作相关类 */ @@ -56,7 +52,7 @@ class MyPsiElementUtil { fun createYamlKeyValueElement(project: Project, key: String, value: String): YAMLKeyValueImpl? { val createYamlDummyFile = createYamlDummyFile(project, "$key : $value") if (createYamlDummyFile != null) { - return PsiTreeUtil.findChildOfType(createYamlDummyFile,YAMLKeyValueImpl::class.java) + return PsiTreeUtil.findChildOfType(createYamlDummyFile, YAMLKeyValueImpl::class.java) } return null } @@ -174,6 +170,38 @@ class MyPsiElementUtil { return map } + fun modifyPsiElementText(psiElement: PsiElement, newText: String) { + // 使用WriteCommandAction来执行修改操作 + WriteCommandAction.runWriteCommandAction(psiElement.project) { + + // 获取当前Psi文件的文档对象 + val document = PsiDocumentManager.getInstance(psiElement.project) + .getDocument(psiElement.containingFile) + if (document != null) { + // 获取要修改的文本范围 + val startOffset = psiElement.textRange.startOffset + val endOffset = psiElement.textRange.endOffset + // 替换文本内容 + document.replaceString(startOffset, endOffset, newText) + // 提交更改并更新Psi文件 + PsiDocumentManager.getInstance(psiElement.project).commitDocument(document) + } + } + } + + fun findAllMatchingElements(psiElement: PsiElement, matchText: (text: String,psiElement: PsiElement) -> Boolean): List { + val matchingElements: MutableList = ArrayList() + if (matchText(psiElement.text,psiElement)) { + matchingElements.add(psiElement) + } + val children = psiElement.children + for (child in children) { + val childMatchingElements: List = findAllMatchingElements(child, matchText) + matchingElements.addAll(childMatchingElements) + } + + return matchingElements + } } @@ -181,6 +209,20 @@ class MyPsiElementUtil { } +fun PsiElement.exByModifyPsiElementText(newText: String) { + MyPsiElementUtil.modifyPsiElementText(this, newText) +} + +fun PsiElement.exByModifyAllPsiElementText(newText: String, oldText: String) { + val children = MyPsiElementUtil.findAllMatchingElements(this) { text,_ -> + return@findAllMatchingElements text == oldText + } + children.forEach { + it.exByModifyPsiElementText(newText) + } + +} + /** * 判断此节点是否为flutter插件 */ diff --git a/src/main/kotlin/shop/itbug/fluttercheckversionx/util/OpenAiUtil.kt b/src/main/kotlin/shop/itbug/fluttercheckversionx/util/OpenAiUtil.kt deleted file mode 100644 index 1b4473bd..00000000 --- a/src/main/kotlin/shop/itbug/fluttercheckversionx/util/OpenAiUtil.kt +++ /dev/null @@ -1,42 +0,0 @@ -package shop.itbug.fluttercheckversionx.util - -import com.aallam.openai.api.BetaOpenAI -import com.aallam.openai.api.chat.ChatCompletionChunk -import com.aallam.openai.api.chat.ChatCompletionRequest -import com.aallam.openai.api.chat.ChatMessage -import com.aallam.openai.api.chat.ChatRole -import com.aallam.openai.api.http.Timeout -import com.aallam.openai.api.model.ModelId -import com.aallam.openai.client.OpenAI -import com.aallam.openai.client.OpenAIConfig -import kotlinx.coroutines.flow.Flow - - -object OpenAiUtil { - - /** - * open ai 实例 - */ - private fun getOpenAi(): OpenAI = OpenAI( - OpenAIConfig( - token = CredentialUtil.openApiKey, - timeout = Timeout() - ) - ) - - @OptIn(BetaOpenAI::class) - fun createQ(q: String): ChatCompletionRequest { - return ChatCompletionRequest( - model = ModelId("gpt-3.5-turbo"), - messages = listOf( - ChatMessage(content = q, role = ChatRole.User) - ) - ) - } - - - @OptIn(BetaOpenAI::class) - fun askSimple(q: String): Flow { - return getOpenAi().chatCompletions(createQ(q)) - } -} \ No newline at end of file diff --git a/src/main/kotlin/shop/itbug/fluttercheckversionx/util/Util.kt b/src/main/kotlin/shop/itbug/fluttercheckversionx/util/Util.kt index b4beca7a..285507f8 100644 --- a/src/main/kotlin/shop/itbug/fluttercheckversionx/util/Util.kt +++ b/src/main/kotlin/shop/itbug/fluttercheckversionx/util/Util.kt @@ -1,9 +1,19 @@ package shop.itbug.fluttercheckversionx.util import com.google.common.base.CaseFormat +import com.intellij.openapi.command.WriteCommandAction +import com.intellij.openapi.editor.Editor +import com.intellij.openapi.util.io.FileUtilRt +import com.intellij.psi.PsiElement +import com.intellij.psi.PsiFile +import com.intellij.psi.codeStyle.CodeStyleManager +import com.intellij.ui.awt.RelativePoint import com.intellij.util.ui.UIUtil +import com.jetbrains.lang.dart.psi.impl.DartFactoryConstructorDeclarationImpl import shop.itbug.fluttercheckversionx.constance.dartKeys +import shop.itbug.fluttercheckversionx.manager.DartFactoryConstructorDeclarationImplManager import java.awt.Color +import java.awt.Point import java.io.BufferedReader import java.io.ByteArrayInputStream import java.io.InputStreamReader @@ -30,6 +40,51 @@ fun String.firstChatToUpper() : String { return CaseFormat.LOWER_HYPHEN.to(CaseFormat.UPPER_CAMEL, this) } +/** + * 格式化文档 + */ +fun PsiElement.reformatText() { + WriteCommandAction.runWriteCommandAction(this.project) { + CodeStyleManager.getInstance(this.project).reformatText(this.containingFile, 0, this.containingFile.textLength) + } +} + + +fun PsiElement.runWriteCommandAction(runnable: Runnable) { + WriteCommandAction.runWriteCommandAction(project,runnable) +} + +/** + * 根据文本查找psi节点 + * @param findText 要查找的文本 + */ +fun PsiFile.findPsiElementByText(findText: String) : PsiElement? { + val c = MyPsiElementUtil.findAllMatchingElements(this){ text: String, psiElement: PsiElement -> + return@findAllMatchingElements findText == text + } + return if(c.isNotEmpty()) c.first() else null +} + +fun PsiElement.getRelativePoint(editor: Editor): RelativePoint { + val startPoint: Point = editor.offsetToXY(textRange.startOffset) + val endPoint: Point = editor.offsetToXY(textRange.endOffset) + val x: Int = (startPoint.x + endPoint.x) / 2 + val y: Int = startPoint.y + return RelativePoint(editor.contentComponent, Point(x, y)) +} + +/** + * 根据psi节点获取文件名 + */ +fun PsiElement.getFileName() : String { + return FileUtilRt.getNameWithoutExtension(this.containingFile.name) +} + + +fun DartFactoryConstructorDeclarationImpl.manager() = DartFactoryConstructorDeclarationImplManager(this) + + + class Util { companion object { @@ -39,16 +94,6 @@ class Util { return UIUtil.colorToHex(color) } - /** - * 字符串转换成Color对象 - * @param colorStr 16进制颜色字符串 - * @return Color对象 - */ - fun toColorFromString(colorStr: String): Color { - var c = colorStr - c = c.substring(4) - return Color(c.toInt(16)) - } fun removeSpecialCharacters(string: String): String { diff --git a/src/main/kotlin/shop/itbug/fluttercheckversionx/util/dart/DartClassUtil.kt b/src/main/kotlin/shop/itbug/fluttercheckversionx/util/dart/DartClassUtil.kt new file mode 100644 index 00000000..c129217f --- /dev/null +++ b/src/main/kotlin/shop/itbug/fluttercheckversionx/util/dart/DartClassUtil.kt @@ -0,0 +1,22 @@ +package shop.itbug.fluttercheckversionx.util.dart + +import com.intellij.psi.PsiElement +import com.intellij.psi.util.PsiTreeUtil +import com.jetbrains.lang.dart.psi.impl.DartClassDefinitionImpl +import com.jetbrains.lang.dart.psi.impl.DartMetadataImpl + +object DartClassUtil { + + /** + * 判断某个类是否有[name]这个注解 + */ + fun hasMetadata(element:PsiElement, name: String):Boolean { + if(element is DartClassDefinitionImpl) { + val metadataList = PsiTreeUtil.findChildrenOfType(element, DartMetadataImpl::class.java) //查找注解列表 + if(metadataList.isNotEmpty()) { + return metadataList.find { it.referenceExpression.text == name } != null + } + } + return false + } +} \ No newline at end of file diff --git a/src/main/kotlin/shop/itbug/fluttercheckversionx/widget/EditorTextPanel.kt b/src/main/kotlin/shop/itbug/fluttercheckversionx/widget/EditorTextPanel.kt index 5945eda7..a1cc6b62 100644 --- a/src/main/kotlin/shop/itbug/fluttercheckversionx/widget/EditorTextPanel.kt +++ b/src/main/kotlin/shop/itbug/fluttercheckversionx/widget/EditorTextPanel.kt @@ -482,11 +482,11 @@ open class EditorTextPanel @JvmOverloads constructor( CellRendererPane::class.java as Class, this as Component ) != null && (StartupUiUtil - .isUnderDarcula() || UIUtil.isUnderIntelliJLaF()) + .isUnderDarcula || UIUtil.isUnderIntelliJLaF()) ) { return parent.background } - if (StartupUiUtil.isUnderDarcula() /* || UIUtil.isUnderIntelliJLaF()*/) return UIUtil.getTextFieldBackground() + if (StartupUiUtil.isUnderDarcula) return UIUtil.getTextFieldBackground() return if (enabled) colorsScheme.defaultBackground else UIUtil.getInactiveTextFieldBackgroundColor() } @@ -533,7 +533,7 @@ open class EditorTextPanel @JvmOverloads constructor( val size: Dimension = JBUI.size(1, 10) if (myEditor != null) { size.height = myEditor!!.lineHeight - if (UIUtil.isUnderDefaultMacTheme() || StartupUiUtil.isUnderDarcula() || UIUtil.isUnderIntelliJLaF()) { + if (UIUtil.isUnderDefaultMacTheme() || StartupUiUtil.isUnderDarcula || UIUtil.isUnderIntelliJLaF()) { size.height = Math.max(size.height, scale(16)) } JBInsets.addTo(size, insets) diff --git a/src/main/kotlin/shop/itbug/fluttercheckversionx/widget/WidgetUtil.kt b/src/main/kotlin/shop/itbug/fluttercheckversionx/widget/WidgetUtil.kt index 43eb5abe..224317f4 100644 --- a/src/main/kotlin/shop/itbug/fluttercheckversionx/widget/WidgetUtil.kt +++ b/src/main/kotlin/shop/itbug/fluttercheckversionx/widget/WidgetUtil.kt @@ -1,6 +1,7 @@ package shop.itbug.fluttercheckversionx.widget import com.intellij.icons.AllIcons +import com.intellij.ide.BrowserUtil import com.intellij.openapi.actionSystem.* import com.intellij.openapi.project.DumbAwareAction import com.intellij.openapi.ui.popup.Balloon @@ -10,6 +11,7 @@ import com.intellij.ui.awt.RelativePoint import com.intellij.ui.components.JBLabel import com.intellij.util.ui.JBUI import shop.itbug.fluttercheckversionx.common.MyDumbAwareAction +import shop.itbug.fluttercheckversionx.constance.discordUrl import shop.itbug.fluttercheckversionx.dialog.RewardDialog import shop.itbug.fluttercheckversionx.document.copyTextToClipboard import shop.itbug.fluttercheckversionx.icons.MyIcons @@ -82,6 +84,18 @@ object WidgetUtil { } } + + /** + * 反馈论坛 + */ + fun getDiscordAction() :AnAction { + return object : MyDumbAwareAction(MyIcons.discord) { + override fun actionPerformed(p0: AnActionEvent) { + BrowserUtil.browse(discordUrl) + } + } + } + /** * 显示一个气球提示文本 */ diff --git a/src/main/kotlin/shop/itbug/fluttercheckversionx/window/FlutterChatMessageWindow.kt b/src/main/kotlin/shop/itbug/fluttercheckversionx/window/FlutterChatMessageWindow.kt index 8e6358f3..6b3585ec 100644 --- a/src/main/kotlin/shop/itbug/fluttercheckversionx/window/FlutterChatMessageWindow.kt +++ b/src/main/kotlin/shop/itbug/fluttercheckversionx/window/FlutterChatMessageWindow.kt @@ -1,6 +1,5 @@ package shop.itbug.fluttercheckversionx.window -import com.alibaba.fastjson2.JSONObject import com.intellij.icons.AllIcons import com.intellij.notification.NotificationType import com.intellij.openapi.Disposable @@ -61,9 +60,11 @@ class FlutterChatMessageWindow(val project: Project, private val toolWindow: Too if (userInfo == null) { showLoginDialog() } else { - println("----${JSONObject.toJSONString(userInfo)}") - JBPopupFactory.getInstance().createComponentPopupBuilder(userDetailSimplePanel(userInfo!!), null) - .createPopup().show(RelativePoint(e.inputEvent.component.locationOnScreen)) + e.inputEvent?.let { + JBPopupFactory.getInstance().createComponentPopupBuilder(userDetailSimplePanel(userInfo!!), null) + .createPopup().show(RelativePoint(it.component.locationOnScreen)) + } + } } diff --git a/src/main/kotlin/shop/itbug/fluttercheckversionx/window/SocketWindow.kt b/src/main/kotlin/shop/itbug/fluttercheckversionx/window/SocketWindow.kt index 304c3fbc..76579ca0 100644 --- a/src/main/kotlin/shop/itbug/fluttercheckversionx/window/SocketWindow.kt +++ b/src/main/kotlin/shop/itbug/fluttercheckversionx/window/SocketWindow.kt @@ -77,6 +77,14 @@ class SocketWindow : ToolWindowFactory { p1.contentManager.addContent(dartPluginContent) + + //简单的一个处理请求的函数 +// val requestPanel = RequestPanelUi(p1,p0) +// val requestPanelContent = instance.createContent(requestPanel,"Simple Request",false) +// p1.contentManager.addContent(requestPanelContent) + } -} \ No newline at end of file +} + +// \ No newline at end of file diff --git a/src/main/resources/META-INF/actions.xml b/src/main/resources/META-INF/actions.xml index f3b890f0..57cd6df7 100644 --- a/src/main/resources/META-INF/actions.xml +++ b/src/main/resources/META-INF/actions.xml @@ -16,7 +16,6 @@ /> - - - - - diff --git a/src/main/resources/META-INF/plugin.xml b/src/main/resources/META-INF/plugin.xml index e5b27525..22b59b56 100644 --- a/src/main/resources/META-INF/plugin.xml +++ b/src/main/resources/META-INF/plugin.xml @@ -42,10 +42,12 @@ ]]> com.intellij.modules.platform + com.intellij.java org.jetbrains.plugins.yaml com.intellij.modules.lang com.intellij.modules.lang Dart + org.jetbrains.idea.maven io.flutter org.jetbrains.kotlin org.intellij.plugins.markdown @@ -94,17 +96,20 @@ - + + + + @@ -120,14 +125,8 @@ implementationClass="shop.itbug.fluttercheckversionx.inlay.dartfile.DartTypeInlayHintsProvider" language="Dart"/> - - - - - - @@ -163,21 +162,11 @@ - - - - - - - - - @@ -188,6 +177,11 @@ class="shop.itbug.fluttercheckversionx.actions.OpenSettingAnAction" text="Setting" icon="/icons/setting.svg"/> + + + diff --git a/src/main/resources/icons/discord.svg b/src/main/resources/icons/discord.svg new file mode 100644 index 00000000..a6f3dda4 --- /dev/null +++ b/src/main/resources/icons/discord.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/main/resources/icons/flutter.svg b/src/main/resources/icons/flutter.svg index 1f9a1bb4..b80305a2 100644 --- a/src/main/resources/icons/flutter.svg +++ b/src/main/resources/icons/flutter.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/src/main/resources/messages/pluginBundle.properties b/src/main/resources/messages/pluginBundle.properties index 4bc63844..a3270af6 100644 --- a/src/main/resources/messages/pluginBundle.properties +++ b/src/main/resources/messages/pluginBundle.properties @@ -2,7 +2,6 @@ account.text = 账号 password.text = 密码 window.chat.loginDialog.text = 登录 -window.chat.loginAndRegister = 登录&注册 window.chat.noMessage = 暂时没有人聊天,快去发言吧 window.chat.sendInput.desc = 说点什么吧 (按Enter键发送) window.chat.loginDialog.register.comment = 没有账号?注册一个 @@ -17,20 +16,13 @@ reward=打赏 help=使用教程 setting=Flutter CheckX 设置 clean=清除记录 -comment.api.new.tips=当监听到接口的时候,在窗口中弹出一个提醒,默认开启 open=开启 setting.new.tips=新接口提醒 setting.reset.tip=重启IDEA生效 setting.language=语言 setting.listening.port=监听端口 -window.idea.dio.view.detail=查看接口的详情信息 -window.idea.dio.view.detail.desc=复制接口 window.idea.dio.view.copy=复制 URL -window.idea.dio.view.copy.desc=清除列表中的全部历史记录 window.idea.dio.view.clean.desc=查看 GET Query 参数 -window.idea.dio.view.query.params=如果API列表选中某个接口,点击此按钮,会弹出改接口URL后面query参数的json类型 -window.idea.dio.view.query.params.desc=未选中请求,无法查看 -window.idea.dio.view.query.params.tip=未选中,无法查看 basic=常规 freezed.title=Json自动生成Freezed对象 freezed.btn.ok=生成 @@ -59,14 +51,8 @@ time=显示时间 bold.link=粗体链接 ass.setting.title=Assets 资产文件智能提醒设置 ass.1=触发文本 -ass.2=字符串类型的输入类型中,监测到该关键字会触发智能提醒实现资产文件自动补全 ass.3=触发长度 -ass.4=默认3,一般使用默认值就可以 ass.5=扫描文件夹 -ass.6=默认assets文件夹 -dio.toolbar.2.1=滚动条自动滚动到最底部 -dio.toolbar.2.2=当接口监听到数据后,滚动条会一直保持在最底部,关闭后保持不变 -dio.toolbar.3.1=使用倒序的方式渲染列表 dio.toolbar.get.params=查看Get查询参数 dio.toolbar.post.params=查看Post请求体 bugs=意见&bug反馈 @@ -82,7 +68,7 @@ add=添加 search=搜索 name.plugin=插件名 menu=菜单 -split.symbol=\ 丨 +split.symbol=\ 丨 auto.scroll.to.the.bottom=自动滚动到底部 view.request.headers=查看请求头 json.viewer=Json查看器 @@ -105,7 +91,6 @@ g.9.1=监听变化 g.9.2=文件更改后自动生成 g.10.1=图标预览 g.10.2=在编辑器中显示图标预览 -g.11=感谢尘定同学提出的建议 g.12=暂无忽略&过滤的文件 g.13=输入要忽略的文件 g.14=此列表中的文件将不进入资产生成循环中 diff --git a/src/main/resources/messages/pluginBundle_en.properties b/src/main/resources/messages/pluginBundle_en.properties index 348dd587..d7230d40 100644 --- a/src/main/resources/messages/pluginBundle_en.properties +++ b/src/main/resources/messages/pluginBundle_en.properties @@ -1,8 +1,7 @@ account.text = Account password.text = Password -window.chat.loginDialog.text=Sign in\ +window.chat.loginDialog.text=Sign in -window.chat.loginAndRegister = Login & Register window.chat.noMessage = No one is chatting for the time being. Go to speak quickly window.chat.sendInput.desc = Say something (press Enter to send) window.chat.loginDialog.register.comment = No account, go to register @@ -17,20 +16,13 @@ reward=Reward help=Tutorials setting=Flutter CheckX Setting clean=Clear Records -comment.api.new.tips=When the interface is monitored, a reminder pops up in the window, which is enabled by default open=Open setting.new.tips=New api reminder setting.reset.tip=Restart IDEA to take effect setting.language=Language setting.listening.port=Listening port -window.idea.dio.view.detail=View request header -window.idea.dio.view.detail.desc=View Details window.idea.dio.view.copy=Copy Url -window.idea.dio.view.copy.desc=Copy the interface link of the selected request to the system's clipboard window.idea.dio.view.clean.desc=Clear all history in the list -window.idea.dio.view.query.params=View GET Query Parameters -window.idea.dio.view.query.params.desc=If you select an interface in the API list and click this button, the json type of query parameter behind the interface URL will pop up -window.idea.dio.view.query.params.tip=Request not selected, unable to view basic=Basic freezed.btn.text=Json to freezed model build.succeeded=Build succeeded! @@ -59,14 +51,8 @@ time=Time bold.link=Bold Link ass.setting.title=Assets asset file intelligent alert settings ass.1=Trigger text -ass.2=In the input type of string type, the detection of this keyword will trigger an intelligent reminder to realize automatic completion of asset files ass.3=Trigger length -ass.4=The default value is 3. Generally, you can use the default value ass.5=Scan Folders -ass.6=Default assets folder -dio.toolbar.2.1=The scroll bar automatically scrolls to the bottom -dio.toolbar.2.2=When the interface listens to data, the scroll bar will remain at the bottom and remain unchanged after closing -dio.toolbar.3.1=Render the list in reverse order dio.toolbar.get.params=View Get query parameters dio.toolbar.post.params=View Post request body bugs=Comments&bug feedback @@ -82,7 +68,7 @@ add=Add search=Search name.plugin=Plugin Name menu=Menus -split.symbol=\ 丨 +split.symbol=\ 丨 auto.scroll.to.the.bottom=Auto Scroll To The Bottom view.request.headers=View request headers json.viewer=Json viewer @@ -105,7 +91,6 @@ g.9.1=Monitor changes g.9.2=Automatically generated after file change g.10.1=Icon preview g.10.2=Show icon preview in editor -g.11=Thank you for 尘定 suggestions g.12=No files to ignore&filter g.13=Enter the file to ignore g.14=Files in this list will not enter the asset generation cycle @@ -124,4 +109,7 @@ flutter.clean=Execute command: flutter clean dart.pub.publish=Execute command: dart pub publish addConstructorFun=Add constructor Function addFromJson=Add FromJson Function -plugin.collect=Collect Plugin \ No newline at end of file +plugin.collect=Collect Plugin +comment.api.new.tips=When monitoring the interface, a reminder pops up in the window, which is enabled by default +window.idea.dio.view.detail=View detailed information of the interface +window.idea.dio.view.detail.desc=Copy Interface diff --git a/src/main/resources/messages/pluginBundle_hk.properties b/src/main/resources/messages/pluginBundle_hk.properties new file mode 100644 index 00000000..fab00112 --- /dev/null +++ b/src/main/resources/messages/pluginBundle_hk.properties @@ -0,0 +1,114 @@ +account.text = 帳戶 +password.text = 密碼 +window.chat.loginDialog.text=登入 +window.chat.noMessage = 暫時沒人聊天。快去說話 +window.chat.sendInput.desc = 說些什麼(按 Enter 發送) +window.chat.loginDialog.register.comment = 沒有賬號,請前往註冊 +window.idea.dio.title=Dio 請求 +window.idea.chat.title = 聊天室 +window.chat.loginDialog.title = 帳號登錄 +window.idea.loginDialog.remember=記住密碼 +switch.rooms=切換房間 +set.default=設為默認 +empty=空 +reward=打賞 +help=教程 +setting=Flutter CheckX 設定 +clean=清除記錄 +open=打開 +setting.new.tips=新API提醒 +setting.reset.tip=重啟IDEA即可生效 +setting.language=語言 +setting.listening.port=監聽端口 +window.idea.dio.view.copy=複製網址 +window.idea.dio.view.clean.desc=清除列表中的所有歷史記錄 +basic=基本 +freezed.btn.text=Json to freezed 模型 +build.succeeded=構建成功! +unable.to.find.directory=找不到目錄 +automatic.operation.command=自動運行命令: +file.name=文件名 +save.to.directory=保存到目錄 +global.settings=全局設置 +cancel=取消 +freezed.btn.ok=產生 +freezed.title=Json to Freezed 模型 +rename=改名 +hump.variable=駝峰變量命名 +variable.is.named.with.hump=變量以駝峰命名 +default.value=使用默認值 +default.value.tip=如果變量為空,則設置默認值 +input.your.json=請輸入您要轉換的 JSON +save.and.refresh=保存並刷新 +json.format.verification.failed=JSON格式驗證失敗 +display_domain_name=顯示域名 +display.query.parameters=顯示查詢參數 +show.request.method=顯示請求方法 +display.status.code=顯示狀態碼 +display.time=顯示請求時間 +time=時間 +bold.link=粗體鏈接 +ass.setting.title=Assets資產文件智能提醒設置 +ass.1=觸發文本 +ass.3=觸髮長度 +ass.5=掃描文件夾 +dio.toolbar.get.params=查看獲取查詢參數 +dio.toolbar.post.params=查看Post請求正文 +bugs=評論&bug反饋 +replace.with=替換 +nav.to=導航 +version.tip.1=這個插件有新版本了 +version.tip.2=更新時間 +clean.cache=清理緩存 +search.pub.plugin=搜索 pub.dev 插件 +check.flutter.plugin=檢查插件依賴版本 +w.t=FlutterCheckVersionX 工具 +add=添加 +search=搜索 +name.plugin=插件名稱 +menu=菜單 +split.symbol=\ 丨 +auto.scroll.to.the.bottom=自動滾動到底部 +view.request.headers=查看請求頭 +json.viewer=Json查看器 +g.1=Class 名稱 +g.2=文件名 +g.3=保存路徑 +g.3.t=例如,如果要保存到lib目錄下的generate目錄,則將此項設置為lib/generate +g.3.t1=配置makefile的存放目錄 +g.4=替換字符 +g.4.1=如果文件名包含這些特殊字符,會自動替換為下線_,多個請用英文逗號分隔 +g.5.1=命名規範 +g.5.2=屬性值大寫 +g.6.1=命名前綴 +g.6.2=名稱 添加文件夾路徑 +g.7.1=命名後綴 +g.7.2=名稱 添加文件類型後綴 +g.8.1=彈出提醒 +g.8.2=每代都不需要彈窗 +g.9.1=監控變化 +g.9.2=文件更改後自動生成 +g.10.1=圖標預覽 +g.10.2=在編輯器中顯示圖標預覽 +g.12=沒有要忽略和過濾的文件 +g.13=輸入要忽略的文件 +g.14=該列表中的文件不會進入資產生成周期 +assets.gen=資產生成 +dart.doc.markdown=Dart 評論 Markdown 編輯器 +doc=文檔 +type=類型 +attributes=屬性 +name=名字 +required=必填 +location=位置 +element=元素 +br.title=FlutterCheckVersionX 工具 +run.build_runner.build=執行命令: build_runner build +flutter.clean=執行命令: flutter clean +dart.pub.publish=執行命令: dart pub publish +addConstructorFun=添加構造函數 +addFromJson=添加FromJson函數 +plugin.collect=收藏插件 +comment.api.new.tips=當監聽到介面的時候,在視窗中彈出一個提醒,默認開啟 +window.idea.dio.view.detail=查看介面的詳情資訊 +window.idea.dio.view.detail.desc=複製介面 diff --git a/src/main/resources/messages/pluginBundle_ja.properties b/src/main/resources/messages/pluginBundle_ja.properties new file mode 100644 index 00000000..5ee87424 --- /dev/null +++ b/src/main/resources/messages/pluginBundle_ja.properties @@ -0,0 +1,115 @@ +account.text=アカウント +password.text=ひそかに言う +window.chat.loginDialog.text=ログイン#ログイン#\ + +window.chat.noMessage=しばらく誰も話していません。早く話しなさい +window.chat.sendInput.desc=何か言って(Enterキーを押して送信) +window.chat.loginDialog.register.comment=アカウントがないので、登録します +window.idea.dio.title=Dio リクエスト +window.idea.chat.title=チャットルーム +window.chat.loginDialog.title=アカウントログイン +window.idea.loginDialog.remember=パスワードを記憶する +switch.rooms=はいでんしつ +set.default=デフォルトに設定 +empty=空のアイテム +reward=に報いる +help=チュートリアル +setting=Flutter CheckX 設定#セッテイ# +clean=レコードの消去 +comment.api.new.tips=インタフェースを傍受しているときは、ウィンドウにアラームをポップアップし、デフォルトでオンにします +open=オープン +setting.new.tips=新しいインタフェースのリマインダ +setting.reset.tip=IDEAの有効化の再起動 +setting.language=言語 +setting.listening.port=リスニング・ポート +window.idea.dio.view.detail=インタフェースの詳細の表示 +window.idea.dio.view.detail.desc=インタフェースのコピー +window.idea.dio.view.copy=URLをコピー +window.idea.dio.view.clean.desc=GET Queryパラメータの表示 +basic=標準 +freezed.btn.text=Json回転freezedモデル +build.succeeded=生成に成功しました! +unable.to.find.directory=ディレクトリが見つかりませんでした! +automatic.operation.command=自動実行コマンド: +file.name=ファイル名 +save.to.directory=ディレクトリに保存 +global.settings=グローバル設定 +cancel=キャンセル +freezed.btn.ok=生成#セイセイ# +freezed.title=Json Freezedオブジェクトの自動生成 +rename=名前を変更 +hump.variable=ラクダピーク変数の命名 +variable.is.named.with.hump=ラクダピーク変数を使用した命名 +default.value=デフォルト値の使用 +default.value.tip=変数がNULLの場合はデフォルト値を設定します +input.your.json=変換するJSONを入力してください +save.and.refresh=保存して更新 +json.format.verification.failed=JSONフォーマットのチェックに失敗しました。有効なJSONを入力してください +display_domain_name=ドメイン名を表示 +display.query.parameters=クエリー・パラメータの表示 +show.request.method=要求メソッドの表示 +display.status.code=ステータスコードを表示 +display.time=要求時間の表示 +time=表示時間 +bold.link=太字リンク +ass.setting.title=Assets アセットファイルのインテリジェントリマインダ設定 +ass.1=テキストのトリガー +ass.3=トリガ長さ +ass.5=フォルダをスキャン +dio.toolbar.get.params=Getクエリーパラメータの表示 +dio.toolbar.post.params=Post要求体の表示 +bugs=意見&バグフィードバック +replace.with=置換後 +nav.to=ジャンプ先 +version.tip.1=このプラグインには新しいバージョンがあります +version.tip.2=更新日時 +clean.cache=キャッシュのクリーンアップ +search.pub.plugin=pub.devプラグインの検索 +check.flutter.plugin=依存バージョン情報のチェック +w.t=FlutterCheckVersionX ツール +add=追加 +search=検索けんさく +name.plugin=プラグイン名 +menu=メニュー +split.symbol=\ 丨 +auto.scroll.to.the.bottom=下まで自動スクロール +view.request.headers=要求ヘッダの表示 +json.viewer=Jsonビューア +g.1=クラス名 +g.2=ファイル名 +g.3=パスを保存 +g.3.t=例:libディレクトリの下のgenerateディレクトリに保存する場合は、このアイテムをlib/generateに設定します +g.3.t1=生成ファイルの格納ディレクトリの構成 +g.4=置換文字 +g.4.1=ファイル名にこれらの特殊文字が含まれている場合は、自動的に下線_、複数は英文カンマで分割してください +g.5.1=命名規則 +g.5.2=属性値の頭文字大文字 +g.6.1=名前付き接頭辞 +g.6.2=フォルダパスの名前付けの追加 +g.7.1=名前付き接尾辞 +g.7.2=名前付きファイルタイプ接尾辞の追加 +g.8.1=ポップアップアラート +g.8.2=生成ごとにポップアップ窓は必要ありません +g.9.1=リスニングの変更 +g.9.2=ファイル変更後に自動的に生成 +g.10.1=アイコンのプレビュー +g.10.2=エディタにアイコンプレビューを表示する +g.12=無視&フィルタされたファイルはありません +g.13=無視するファイルを入力 +g.14=このリスト内のファイルは資産生成ループに入らない +assets.gen=資産の生成 +dart.doc.markdown=Dart注釈markdownエディタ +doc=ドキュメント +type=を選択してオプションを設定します。 +attributes=属性#ゾクセイ# +name=の名前をあげる +required=必須 +location=位置 +element=ノード +br.title=FlutterCheckVersionX ツール +run.build_runner.build=コマンドの実行: build_runner build +flutter.clean=コマンドの実行: flutter clean +dart.pub.publish=コマンドの実行: dart pub publish +addConstructorFun=コンストラクタの追加 +addFromJson=FromJson関数の追加 +plugin.collect=コレクション \ No newline at end of file diff --git a/src/main/resources/messages/pluginBundle_ko.properties b/src/main/resources/messages/pluginBundle_ko.properties new file mode 100644 index 00000000..76a0c95a --- /dev/null +++ b/src/main/resources/messages/pluginBundle_ko.properties @@ -0,0 +1,115 @@ +account.text=계정 +password.text=은어 +window.chat.loginDialog.text=로그인\ + +window.chat.noMessage=당분간 아무도 이야기를 나누고 있지 않다.빨리 가서 얘기해 +window.chat.sendInput.desc=뭐라도 말해(Enter 키를 눌러 전송) +window.chat.loginDialog.register.comment=계좌 없어요 등록하세요 +window.idea.dio.title=Dio 요청 +window.idea.chat.title=채팅방 +window.chat.loginDialog.title=계정 로그인 +window.idea.loginDialog.remember=비밀번호 기억하기 +switch.rooms=배전실 +set.default=기본값으로 설정 +empty=빈 항목 +reward=보상 +help=자습서 +setting=Flutter CheckX 설치 +clean=레코드 지우기 +comment.api.new.tips=인터페이스를 감지할 때 창에 알림이 뜨고 기본적으로 켜짐 +open=오픈 +setting.new.tips=새 인터페이스 알림 +setting.reset.tip=IDEA 재시작 유효 +setting.language=언어 +setting.listening.port=수신 포트 +window.idea.dio.view.detail=인터페이스 상세 정보 보기 +window.idea.dio.view.detail.desc=복제 인터페이스 +window.idea.dio.view.copy=URL 복사 +window.idea.dio.view.clean.desc=Clear all history in the list +basic=일반 +freezed.btn.text=Json 회전 freezed 모델 +build.succeeded=생성 성공! +unable.to.find.directory=이 디렉터리를 찾을 수 없습니다! +automatic.operation.command=자동 실행 명령: +file.name=파일 이름 +save.to.directory=디렉토리에 저장 +global.settings=전역 설정 +cancel=취소 +freezed.btn.ok=생성 +freezed.title=Json은 Freezed 객체를 자동으로 생성합니다. +rename=이름 바꾸기 +hump.variable=낙타 봉 변수 이름 지정 +variable.is.named.with.hump=낙타 봉 변수를 사용하여 이름 지정 +default.value=기본값 사용 +default.value.tip=변수가 비어 있는 경우 기본값 설정 +input.your.json=변환할 JSON을 입력하십시오. +save.and.refresh=저장 및 새로 고침 +json.format.verification.failed=JSON 형식 검증에 실패했습니다. 올바른 JSON을 입력하십시오. +display_domain_name=도메인 이름 표시 +display.query.parameters=질의 매개변수 표시 +show.request.method=요청 방법 표시 +display.status.code=상태 코드 표시 +display.time=요청 표시 시간 소요 +time=표시 시간 +bold.link=굵은 링크 +ass.setting.title=Assets 자산 파일 지능형 알림 설정 +ass.1=트리거 텍스트 +ass.3=트리거 길이 +ass.5=폴더 검색 +dio.toolbar.get.params=Get 질의 매개변수 보기 +dio.toolbar.post.params=Post 요청체 보기 +bugs=의견 & 버그 피드백 +replace.with=다음으로 교체 +nav.to=다음으로 이동 +version.tip.1=이 플러그인의 새 버전 +version.tip.2=업데이트 시간 +clean.cache=캐시 정리 +search.pub.plugin=pub.dev 플러그인 검색 +check.flutter.plugin=종속 버전 정보 확인 +w.t=FlutterCheckVersionX 도구 +add=추가 +search=검색 +name.plugin=플러그인 이름 +menu=메뉴 +split.symbol=\ 丨 +auto.scroll.to.the.bottom=끝까지 자동 스크롤 +view.request.headers=요청 헤더 보기 +json.viewer=Json 뷰어 +g.1=클래스 이름 +g.2=파일 이름 +g.3=경로 저장 +g.3.t=예: lib 디렉토리의 generate 디렉토리에 저장하려면 lib/generate 로 설정하십시오. +g.3.t1=생성된 파일의 스토리지 디렉토리 구성 +g.4=대체 문자 +g.4.1=파일 이름에 이러한 특수 문자가 포함되어 있으면 에서 자동으로 아래쪽 줄로 바뀝니다.여러 개를 쉼표로 나누십시오. +g.5.1=명명 사양 +g.5.2=속성 값 머리글 대문자 +g.6.1=이름 지정 접두사 +g.6.2=이름 지정 폴더 경로 추가 +g.7.1=이름 지정 접미어 +g.7.2=이름 추가 파일 유형 접미어 +g.8.1=탄창 알림 +g.8.2=생성할 때마다 총알창 필요 없음 +g.9.1=변경 내용 수신 +g.9.2=파일 변경 후 자동 생성 +g.10.1=아이콘 미리 보기 +g.10.2=편집기에 아이콘 미리 보기 표시 +g.12=무시 및 필터링된 파일 없음 +g.13=무시할 파일 가져오기 +g.14=이 목록의 파일은 자산 생성 주기에 들어가지 않습니다. +assets.gen=자산 생성 +dart.doc.markdown=Dart 주석 markdown 편집기 +doc=문서 +type=유형 +attributes=속성 +name=이름 +required=필수 +location=위치 +element=노드 +br.title=FlutterCheckVersionX 도구 +run.build_runner.build=명령 실행: build_runner build +flutter.clean=명령 실행: flutter clean +dart.pub.publish=명령 실행: dart pub publish +addConstructorFun=생성자 추가 +addFromJson=FromJson 함수 추가 +plugin.collect=모음집 \ No newline at end of file