From 4655adbd56fdb9addfdf1a1b2f31ba76c3fa8b3f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=A2=81=E5=85=B8=E5=85=B8?= <413153189@qq.com>
Date: Wed, 8 May 2024 15:27:26 +0800
Subject: [PATCH] release1.5.1
---
CHANGELOG.md | 6 ++
DESCRIPTION.md | 30 +++++++
build.gradle.kts | 9 +-
.../action/rightmenu/AntdRequestCopyAction.kt | 31 +++++++
.../action/rightmenu/CopyUrlAction.kt | 30 +++++++
.../itbug/salvorstool/model/SalvoApiItem.kt | 89 ++++++++++++++++---
.../searcheverywhere/SalvoSearchApi.kt | 1 -
.../salvorstool/tool/ExtendedFuntions.kt | 16 +++-
.../salvorstool/tool/MyRsPsiElementManager.kt | 1 -
.../salvorstool/tool/RsFunctionManager.kt | 6 +-
.../salvorstool/tool/RsMethodCallManager.kt | 10 ++-
.../widget/TypeJavaScriptEditor.kt | 4 -
.../itbug/salvorstool/window/ApiScanWindow.kt | 82 +++++++++++++----
src/main/resources/META-INF/plugin.xml | 17 ++--
.../messages/pluginBundle.properties | 2 +
.../messages/pluginBundle_ar.properties | 2 +
.../messages/pluginBundle_de.properties | 2 +
.../messages/pluginBundle_en.properties | 2 +
.../messages/pluginBundle_fr.properties | 2 +
.../messages/pluginBundle_hk.properties | 2 +
.../messages/pluginBundle_it.properties | 2 +
.../messages/pluginBundle_ja.properties | 2 +
.../messages/pluginBundle_ko.properties | 2 +
.../messages/pluginBundle_nl.properties | 2 +
.../messages/pluginBundle_pl.properties | 2 +
.../messages/pluginBundle_pt.properties | 2 +
.../messages/pluginBundle_ru.properties | 2 +
27 files changed, 309 insertions(+), 49 deletions(-)
create mode 100644 DESCRIPTION.md
create mode 100644 src/main/kotlin/shop/itbug/salvorstool/action/rightmenu/AntdRequestCopyAction.kt
create mode 100644 src/main/kotlin/shop/itbug/salvorstool/action/rightmenu/CopyUrlAction.kt
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 67d04c4..a43fc46 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,12 @@
## Unreleased
+## [1.5.1] - 2024-05-08
+
+- 适配RustRover2024.1.EAP
+- 添加api右键菜单相关功能
+-
更新日志
+
## [1.5.0] - 2024-04-28
- 添加salvo api 接口搜索功能
diff --git a/DESCRIPTION.md b/DESCRIPTION.md
new file mode 100644
index 0000000..1647966
--- /dev/null
+++ b/DESCRIPTION.md
@@ -0,0 +1,30 @@
+SalvoRsTool
+
+
+
+ Document |
+ Github |
+ Get Started |
+ Changelog |
+ Donate
+
+
+
+Features
+
+ - Salvo
+
+ - Generate DTO
+ - Generate Router
+ - Generate Service
+ - Salvo Api Window
+
+
+ - Antd
+
+ - Struct generate Form
+ - Struct generate Table column properties
+ - Struct generate typescript interface
+
+
+
\ No newline at end of file
diff --git a/build.gradle.kts b/build.gradle.kts
index 276ad9c..9c575b7 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -7,7 +7,7 @@ plugins {
}
group = "shop.itbug"
-version = "1.5.0"
+version = "1.5.1"
repositories {
mavenCentral()
@@ -16,7 +16,7 @@ repositories {
intellij {
version.set("LATEST-EAP-SNAPSHOT")
type.set("RR")
- plugins.set(listOf("com.jetbrains.rust","JavaScript"))
+ plugins.set(listOf("com.jetbrains.rust","JavaScriptBase"))
}
val pushToken: String? = System.getenv("PUBLISH_TOKEN")
@@ -42,10 +42,15 @@ tasks {
)
}
+ val descText = projectDir.resolve("DESCRIPTION.md").readText()
+
+ println(descText)
+
patchPluginXml {
sinceBuild.set("232")
untilBuild.set("242.*")
changeNotes.set(myChangeLog)
+ pluginDescription.set(descText)
}
signPlugin {
diff --git a/src/main/kotlin/shop/itbug/salvorstool/action/rightmenu/AntdRequestCopyAction.kt b/src/main/kotlin/shop/itbug/salvorstool/action/rightmenu/AntdRequestCopyAction.kt
new file mode 100644
index 0000000..217b781
--- /dev/null
+++ b/src/main/kotlin/shop/itbug/salvorstool/action/rightmenu/AntdRequestCopyAction.kt
@@ -0,0 +1,31 @@
+package shop.itbug.salvorstool.action.rightmenu
+
+import com.intellij.icons.AllIcons
+import com.intellij.openapi.actionSystem.ActionUpdateThread
+import com.intellij.openapi.actionSystem.AnAction
+import com.intellij.openapi.actionSystem.AnActionEvent
+import shop.itbug.salvorstool.i18n.MyI18n
+import shop.itbug.salvorstool.tool.copy
+import shop.itbug.salvorstool.window.ApiScanWindow.Companion.JListSelectItemDataKey
+
+/**
+ * 拷贝antd request 请求
+ */
+class AntdRequestCopyAction : AnAction() {
+ override fun actionPerformed(e: AnActionEvent) {
+ val item = e.getData(JListSelectItemDataKey)!!
+ val str = item.generateAntdRequest()
+ str.copy()
+ }
+
+ override fun update(e: AnActionEvent) {
+ super.update(e)
+ e.presentation.text = "${MyI18n.getMessage("copy")} Antd Request"
+ e.presentation.icon = AllIcons.Actions.Copy
+ e.presentation.isEnabled = e.getData(JListSelectItemDataKey) != null
+ }
+
+ override fun getActionUpdateThread(): ActionUpdateThread {
+ return ActionUpdateThread.BGT
+ }
+}
diff --git a/src/main/kotlin/shop/itbug/salvorstool/action/rightmenu/CopyUrlAction.kt b/src/main/kotlin/shop/itbug/salvorstool/action/rightmenu/CopyUrlAction.kt
new file mode 100644
index 0000000..b3cf021
--- /dev/null
+++ b/src/main/kotlin/shop/itbug/salvorstool/action/rightmenu/CopyUrlAction.kt
@@ -0,0 +1,30 @@
+package shop.itbug.salvorstool.action.rightmenu
+
+import com.intellij.icons.AllIcons
+import com.intellij.openapi.actionSystem.ActionUpdateThread
+import com.intellij.openapi.actionSystem.AnAction
+import com.intellij.openapi.actionSystem.AnActionEvent
+import shop.itbug.salvorstool.i18n.MyI18n
+import shop.itbug.salvorstool.tool.copy
+import shop.itbug.salvorstool.window.ApiScanWindow.Companion.JListSelectItemDataKey
+
+class CopyUrlAction : AnAction() {
+
+ override fun actionPerformed(e: AnActionEvent) {
+ val item = e.getData(JListSelectItemDataKey)!!
+ item.api.copy()
+ }
+
+ override fun update(e: AnActionEvent) {
+ with(e.presentation) {
+ isEnabled = e.getData(JListSelectItemDataKey) != null
+ text = "${MyI18n.getMessage("copy")} URL"
+ icon = AllIcons.Actions.Copy
+ }
+ super.update(e)
+ }
+
+ override fun getActionUpdateThread(): ActionUpdateThread {
+ return ActionUpdateThread.BGT
+ }
+}
diff --git a/src/main/kotlin/shop/itbug/salvorstool/model/SalvoApiItem.kt b/src/main/kotlin/shop/itbug/salvorstool/model/SalvoApiItem.kt
index 9659d09..07f7a53 100644
--- a/src/main/kotlin/shop/itbug/salvorstool/model/SalvoApiItem.kt
+++ b/src/main/kotlin/shop/itbug/salvorstool/model/SalvoApiItem.kt
@@ -4,9 +4,10 @@ import com.intellij.openapi.application.ApplicationManager
import com.intellij.openapi.fileEditor.FileEditorManager
import com.intellij.openapi.project.Project
import com.intellij.pom.Navigatable
+import com.intellij.psi.search.searches.ReferencesSearch
import org.rust.lang.core.psi.RsMethodCall
-
-
+import shop.itbug.salvorstool.tool.*
+import java.util.*
enum class SalvoApiItemMethod {
@@ -21,15 +22,81 @@ data class SalvoApiItem(val api: String,val method: SalvoApiItemMethod,val rsMet
override fun toString(): String {
return "\n${api} - $method"
}
-}
-fun SalvoApiItem.navTo(project: Project) {
- val navigationElement = rsMethodPsiElement.navigationElement
- ApplicationManager.getApplication().invokeLater {
- if (navigationElement != null && navigationElement is Navigatable && (navigationElement as Navigatable).canNavigate()) {
- (navigationElement as Navigatable).navigate(true)
- }else{
- FileEditorManager.getInstance(project).openFile(rsMethodPsiElement.containingFile.virtualFile)
+ /**
+ * 生成antd request
+ */
+ fun generateAntdRequest(): String {
+ val sb = StringBuilder()
+ sb.appendLine("export async function ${generateRequestName()}(${generateFunctionParams()}) : Promise{")
+ sb.appendLine("\treturn request(`${replaceAngleBracketsWithDollarCurlyBrackets(api)}`,{")
+ sb.appendLine("\t\tmethod: '${method.name.uppercase(Locale.getDefault())}',")
+ sb.appendLine("\t})")
+ sb.appendLine("}")
+ return sb.toString()
+ }
+
+ /**
+ * 函数名称
+ */
+ private fun generateRequestName(): String {
+ val name = removeIdWithSlash(api).replace("/","_").underlineToCamel.capitalizeFirstLetter()
+ return firstCharToLowercase(name)
+ }
+
+
+ /**
+ * 去除/这种文本
+ */
+ private fun removeIdWithSlash(input: String): String {
+ val pattern = """\/<[^>]+>""".toRegex()
+ return pattern.replace(input, "")
+ }
+
+ /**
+ * 获取url参数
+ */
+ private fun extractBracketContents(input: String): List {
+ val pattern = """<([^>]+)>""".toRegex()
+ return pattern.findAll(input).map { it.groupValues[1] }.toList()
+ }
+
+
+ /**
+ * 替换->${id}
+ */
+ private fun replaceAngleBracketsWithDollarCurlyBrackets(input: String): String {
+ val angleBracketsContentPattern = """<([^>]+)>""".toRegex()
+ return angleBracketsContentPattern.replace(input) { "\${${it.groupValues[1]}}" }
+ }
+
+ /**
+ * 生成参数列表
+ */
+ private fun generateFunctionParams() : String {
+ val params = extractBracketContents(api)
+ if(params.isNotEmpty()){
+ val sb = StringBuilder()
+ params.forEach {
+ sb.append("${it}: string,")
+ }
+ return sb.toString().removeSuffix(",")
}
+ return ""
}
-}
\ No newline at end of file
+
+
+ /**
+ * 跳到代码位置
+ */
+ fun navTo(project: Project) {
+ val navigationElement = rsMethodPsiElement.navigationElement
+ ApplicationManager.getApplication().invokeLater {
+ if (navigationElement != null && navigationElement is Navigatable && (navigationElement as Navigatable).canNavigate()) {
+ (navigationElement as Navigatable).navigate(true)
+ }else{
+ FileEditorManager.getInstance(project).openFile(rsMethodPsiElement.containingFile.virtualFile)
+ }
+ }
+ }
+}
diff --git a/src/main/kotlin/shop/itbug/salvorstool/searcheverywhere/SalvoSearchApi.kt b/src/main/kotlin/shop/itbug/salvorstool/searcheverywhere/SalvoSearchApi.kt
index 2280e16..3e0ae6b 100644
--- a/src/main/kotlin/shop/itbug/salvorstool/searcheverywhere/SalvoSearchApi.kt
+++ b/src/main/kotlin/shop/itbug/salvorstool/searcheverywhere/SalvoSearchApi.kt
@@ -7,7 +7,6 @@ import com.intellij.openapi.progress.ProgressIndicator
import com.intellij.openapi.project.Project
import com.intellij.util.Processor
import shop.itbug.salvorstool.model.SalvoApiItem
-import shop.itbug.salvorstool.model.navTo
import shop.itbug.salvorstool.service.SalvoApiService
import shop.itbug.salvorstool.window.SalvoApiItemRender
import javax.swing.ListCellRenderer
diff --git a/src/main/kotlin/shop/itbug/salvorstool/tool/ExtendedFuntions.kt b/src/main/kotlin/shop/itbug/salvorstool/tool/ExtendedFuntions.kt
index 2fd08f8..03861e3 100644
--- a/src/main/kotlin/shop/itbug/salvorstool/tool/ExtendedFuntions.kt
+++ b/src/main/kotlin/shop/itbug/salvorstool/tool/ExtendedFuntions.kt
@@ -17,20 +17,30 @@ val PsiElement.myManager get() = MyRsPsiElementManager(this)
val RsStructItemImpl.myManager get() = MyRsStructManager(this)
val RsNamedFieldDecl.myManager get() = MyFieldPsiElementManager(this)
val RsOuterAttr.myManager get() = MyRsOuterAttrPsiElementManager(this)
+
+///首字母变大小
fun String.capitalizeFirstLetter(): String {
if (isEmpty()) {
return this
}
return substring(0, 1).uppercase(Locale.getDefault()) + substring(1)
}
-///
+///下划线变驼峰
val String.underlineToCamel: String get() = underlineToCamel(this)
///将驼峰变成下划线
fun underlineToCamel(underlineString: String): String {
return CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, underlineString)
}
-
-
+///首字母变小写
+fun firstCharToLowercase(input: String): String {
+ if (input.isEmpty() || input.length == 1) return input
+ val firstChar = input[0]
+ return if (firstChar.isUpperCase()) {
+ firstChar.lowercase() + input.substring(1)
+ } else {
+ input
+ }
+}
fun AnActionEvent.tryGetRsStructPsiElement(): RsStructItemImpl? {
val psiElement = this.getData(CommonDataKeys.PSI_ELEMENT)
diff --git a/src/main/kotlin/shop/itbug/salvorstool/tool/MyRsPsiElementManager.kt b/src/main/kotlin/shop/itbug/salvorstool/tool/MyRsPsiElementManager.kt
index 5727496..dfd6523 100644
--- a/src/main/kotlin/shop/itbug/salvorstool/tool/MyRsPsiElementManager.kt
+++ b/src/main/kotlin/shop/itbug/salvorstool/tool/MyRsPsiElementManager.kt
@@ -3,7 +3,6 @@ package shop.itbug.salvorstool.tool
import com.intellij.psi.PsiElement
import com.intellij.psi.impl.source.tree.PsiCommentImpl
import com.intellij.psi.util.PsiTreeUtil
-import com.intellij.psi.util.lastLeaf
import org.rust.lang.core.psi.RsMetaItem
import org.rust.lang.core.psi.RsNamedFieldDecl
import org.rust.lang.core.psi.RsOuterAttr
diff --git a/src/main/kotlin/shop/itbug/salvorstool/tool/RsFunctionManager.kt b/src/main/kotlin/shop/itbug/salvorstool/tool/RsFunctionManager.kt
index 367bb16..b357243 100644
--- a/src/main/kotlin/shop/itbug/salvorstool/tool/RsFunctionManager.kt
+++ b/src/main/kotlin/shop/itbug/salvorstool/tool/RsFunctionManager.kt
@@ -3,18 +3,16 @@ package shop.itbug.salvorstool.tool
import com.intellij.psi.util.PsiTreeUtil
import org.rust.lang.core.psi.RsTypeReference
import org.rust.lang.core.psi.ext.block
-import org.rust.lang.core.psi.ext.leftLeaves
import org.rust.lang.core.psi.impl.RsFunctionImpl
import org.rust.lang.core.psi.impl.RsLetDeclImpl
-import org.rust.lang.core.psi.impl.RsPathTypeImpl
val RsFunctionImpl.myManager: RsFunctionManager get() = RsFunctionManager(this)
///rs fun tool
-class RsFunctionManager(val rsFunction: RsFunctionImpl) {
+class RsFunctionManager(private val rsFunction: RsFunctionImpl) {
//获取返回类型
- fun getReturnType() : RsTypeReference? {
+ private fun getReturnType() : RsTypeReference? {
val returnType = rsFunction.retType ?: return null
return returnType.typeReference
}
diff --git a/src/main/kotlin/shop/itbug/salvorstool/tool/RsMethodCallManager.kt b/src/main/kotlin/shop/itbug/salvorstool/tool/RsMethodCallManager.kt
index c51c4fa..a6321ec 100644
--- a/src/main/kotlin/shop/itbug/salvorstool/tool/RsMethodCallManager.kt
+++ b/src/main/kotlin/shop/itbug/salvorstool/tool/RsMethodCallManager.kt
@@ -5,7 +5,7 @@ import com.intellij.psi.util.PsiTreeUtil
import org.rust.lang.core.psi.RsMethodCall
import org.rust.lang.core.psi.impl.RsDotExprImpl
import org.rust.lang.core.psi.impl.RsLetDeclImpl
-import org.rust.lang.core.psi.impl.RsMethodCallImpl
+import org.rust.lang.core.psi.impl.RsPathExprImpl
import shop.itbug.salvorstool.model.SalvoApiItem
import shop.itbug.salvorstool.model.SalvoApiItemMethod
import java.util.*
@@ -15,7 +15,6 @@ val RsMethodCall.methodManager: RsMethodCallManager get() = RsMethodCallManager(
/// method call
class RsMethodCallManager(val psiElement: RsMethodCall) {
-
private val myIdText: String get() = psiElement.identifier.text
//是否有push函数
@@ -28,6 +27,13 @@ class RsMethodCallManager(val psiElement: RsMethodCall) {
return PsiTreeUtil.findChildOfType(va, RsDotExprImpl::class.java)
}
+ // rsPath
+ val rsPathChild: RsPathExprImpl?
+ get() {
+ val va = psiElement.valueArgumentList
+ return PsiTreeUtil.findChildOfType(va, RsPathExprImpl::class.java)
+ }
+
// method
val myApiMethod: SalvoApiItemMethod?
get() {
diff --git a/src/main/kotlin/shop/itbug/salvorstool/widget/TypeJavaScriptEditor.kt b/src/main/kotlin/shop/itbug/salvorstool/widget/TypeJavaScriptEditor.kt
index b8f4f07..dbeec64 100644
--- a/src/main/kotlin/shop/itbug/salvorstool/widget/TypeJavaScriptEditor.kt
+++ b/src/main/kotlin/shop/itbug/salvorstool/widget/TypeJavaScriptEditor.kt
@@ -1,16 +1,12 @@
package shop.itbug.salvorstool.widget
-import com.intellij.ide.ui.UITheme
import com.intellij.lang.Language
import com.intellij.lang.javascript.dialects.TypeScriptJSXLanguageDialect
import com.intellij.openapi.editor.colors.EditorColorsManager
import com.intellij.openapi.editor.colors.EditorFontType
import com.intellij.openapi.editor.ex.EditorEx
-import com.intellij.openapi.fileEditor.FileEditorManager
import com.intellij.openapi.project.Project
import com.intellij.ui.LanguageTextField
-import com.intellij.util.ui.JBFont
-import org.rust.lang.RsLanguage
import java.awt.Font
import javax.swing.BorderFactory
import javax.swing.border.Border
diff --git a/src/main/kotlin/shop/itbug/salvorstool/window/ApiScanWindow.kt b/src/main/kotlin/shop/itbug/salvorstool/window/ApiScanWindow.kt
index b43d6ae..23ed968 100644
--- a/src/main/kotlin/shop/itbug/salvorstool/window/ApiScanWindow.kt
+++ b/src/main/kotlin/shop/itbug/salvorstool/window/ApiScanWindow.kt
@@ -1,22 +1,29 @@
package shop.itbug.salvorstool.window
import com.intellij.icons.AllIcons
+import com.intellij.ide.DataManager
import com.intellij.openapi.actionSystem.ActionManager
+import com.intellij.openapi.actionSystem.DataKey
+import com.intellij.openapi.actionSystem.DataProvider
import com.intellij.openapi.actionSystem.DefaultActionGroup
import com.intellij.openapi.application.ApplicationManager
import com.intellij.openapi.project.Project
+import com.intellij.openapi.ui.popup.JBPopupFactory
+import com.intellij.openapi.ui.popup.ListPopup
import com.intellij.openapi.wm.ToolWindow
import com.intellij.ui.ColoredListCellRenderer
import com.intellij.ui.ColoredText
import com.intellij.ui.SearchTextField
import com.intellij.ui.SimpleTextAttributes
+import com.intellij.ui.awt.RelativePoint
import com.intellij.ui.components.JBList
import com.intellij.util.ui.components.BorderLayoutPanel
import shop.itbug.salvorstool.i18n.MyI18n
import shop.itbug.salvorstool.messageing.ApiScanMessaging
import shop.itbug.salvorstool.model.SalvoApiItem
-import shop.itbug.salvorstool.model.navTo
import shop.itbug.salvorstool.service.SalvoApiService
+import java.awt.event.MouseAdapter
+import java.awt.event.MouseEvent
import java.util.*
import javax.swing.*
import javax.swing.event.DocumentEvent
@@ -25,19 +32,30 @@ import javax.swing.event.ListSelectionEvent
import javax.swing.event.ListSelectionListener
-class ApiScanWindow(private val myProject: Project, toolWindow: ToolWindow) : BorderLayoutPanel(), ListSelectionListener {
+class ApiScanWindow(private val myProject: Project, toolWindow: ToolWindow) : BorderLayoutPanel(),
+ ListSelectionListener {
private val list = JBList().apply {
- this.border = BorderFactory.createEmptyBorder(0,0,0,0)
+ this.border = BorderFactory.createEmptyBorder(0, 0, 0, 0)
this.selectionMode = ListSelectionModel.SINGLE_SELECTION
this.addListSelectionListener(this@ApiScanWindow)
+ this.addMouseListener(RightMenuAction())
+ this.setDataProvider {
+ if (it == JListSelectItemDataKey.name){
+ return@setDataProvider this.selectedValue
+ }
+ return@setDataProvider null
+ }
}
- private var allApis = SalvoApiService.getInstance(myProject).getApiList()
+ private var allApis = SalvoApiService.getInstance(myProject).getApiList()
private var searchTextField = MySearchTextField()
private val actions = ActionManager.getInstance().getAction("SalvoApiActionList") as DefaultActionGroup
private val toolbar = ActionManager.getInstance().createActionToolbar("Salvorstool Window", actions, true)
+ companion object {
+ val JListSelectItemDataKey = DataKey.create("listSelectItemDataKey")
+ }
init {
toolbar.targetComponent = toolWindow.component
@@ -46,15 +64,15 @@ class ApiScanWindow(private val myProject: Project, toolWindow: ToolWindow) : Bo
addToRight(toolbar.component)
})
addToCenter(JScrollPane(list).apply {
- this.border = BorderFactory.createEmptyBorder(0,0,0,0)
+ this.border = BorderFactory.createEmptyBorder(0, 0, 0, 0)
})
list.cellRenderer = SalvoApiItemRender()
listenChange()
}
- private fun listenChange(){
- myProject.messageBus.connect().subscribe(ApiScanMessaging.TOPIC,object : ApiScanMessaging {
+ private fun listenChange() {
+ myProject.messageBus.connect().subscribe(ApiScanMessaging.TOPIC, object : ApiScanMessaging {
override fun apiScanEed(apiList: List) {
allApis = apiList
list.model = ItemModel(apiList)
@@ -65,7 +83,7 @@ class ApiScanWindow(private val myProject: Project, toolWindow: ToolWindow) : Bo
override fun valueChanged(e: ListSelectionEvent?) {
e?.let {
- if(!it.valueIsAdjusting){
+ if (!it.valueIsAdjusting) {
val selectedIndex = list.selectedIndex
if (selectedIndex != -1) {
list.selectedValue.navTo(myProject)
@@ -75,16 +93,16 @@ class ApiScanWindow(private val myProject: Project, toolWindow: ToolWindow) : Bo
}
fun startFilterApi(search: String) {
- val filterList = if (search.isEmpty()){
+ val filterList = if (search.isEmpty()) {
allApis
- }else{
+ } else {
allApis.filter { it.api.contains(search) }
}
list.model = ItemModel(filterList)
}
- private inner class MySearchTextField : SearchTextField(false),DocumentListener {
+ private inner class MySearchTextField : SearchTextField(false), DocumentListener {
init {
addDocumentListener(this)
@@ -103,9 +121,9 @@ class ApiScanWindow(private val myProject: Project, toolWindow: ToolWindow) : Bo
handle(e)
}
- private fun handle(e: DocumentEvent?){
+ private fun handle(e: DocumentEvent?) {
e?.document?.let {
- val text = it.getText(0,it.length)
+ val text = it.getText(0, it.length)
startFilterApi(text)
}
}
@@ -119,10 +137,36 @@ class ApiScanWindow(private val myProject: Project, toolWindow: ToolWindow) : Bo
}
}
+ //右键菜单操作
+ inner class RightMenuAction : MouseAdapter(){
+ override fun mouseClicked(e: MouseEvent?) {
+ e?.let {
+ if(SwingUtilities.isRightMouseButton(e)) {
+ val selectIndex = list.locationToIndex(e.point)
+ list.selectedIndex = selectIndex
+ createPopup().show(RelativePoint(list,e.point))
+ }
+ }
+ }
+
+ private fun createPopup(): ListPopup {
+ val ctx = DataManager.getInstance().getDataContext(list)
+ return JBPopupFactory.getInstance().createActionGroupPopup("操作",getActionGroup(),ctx,false,{},10)
+ }
+
+ private fun getActionGroup(): DefaultActionGroup {
+ return ActionManager.getInstance().getAction("SalvoApiRightMenuActionGroup") as DefaultActionGroup
+ }
+ }
}
- class SalvoApiItemRender : ColoredListCellRenderer() {
+
+
+
+
+
+class SalvoApiItemRender : ColoredListCellRenderer() {
override fun customizeCellRenderer(
list: JList,
value: SalvoApiItem?,
@@ -136,12 +180,18 @@ class ApiScanWindow(private val myProject: Project, toolWindow: ToolWindow) : Bo
appendTextPadding(15)
ApplicationManager.getApplication().runReadAction {
append(
- ColoredText.builder().append(" (${it.rsMethodPsiElement.containingFile.name})", SimpleTextAttributes.GRAY_ATTRIBUTES)
+ ColoredText.builder().append(
+ " (${it.rsMethodPsiElement.containingFile.name})",
+ SimpleTextAttributes.GRAY_ATTRIBUTES
+ )
.build()
)
}
append(
- ColoredText.builder().append(" [${it.method.name.uppercase(Locale.getDefault())}]", SimpleTextAttributes.GRAY_ATTRIBUTES)
+ ColoredText.builder().append(
+ " [${it.method.name.uppercase(Locale.getDefault())}]",
+ SimpleTextAttributes.GRAY_ATTRIBUTES
+ )
.build()
)
}
diff --git a/src/main/resources/META-INF/plugin.xml b/src/main/resources/META-INF/plugin.xml
index 6f54469..93fa07c 100644
--- a/src/main/resources/META-INF/plugin.xml
+++ b/src/main/resources/META-INF/plugin.xml
@@ -1,13 +1,10 @@
-
+
shop.itbug.SalvoRsTool
SalvoRsTool
梁典典
-
com.intellij.modules.platform
com.jetbrains.rust
- JavaScript
+ JavaScriptBase
messages.pluginBundle
@@ -46,5 +43,15 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/main/resources/messages/pluginBundle.properties b/src/main/resources/messages/pluginBundle.properties
index c09aa5a..848d1d3 100644
--- a/src/main/resources/messages/pluginBundle.properties
+++ b/src/main/resources/messages/pluginBundle.properties
@@ -12,3 +12,5 @@ g_service=生成service
g_router=生成router
filter_salvo_api_list=输入关键字过滤
+
+copy=拷贝
diff --git a/src/main/resources/messages/pluginBundle_ar.properties b/src/main/resources/messages/pluginBundle_ar.properties
index 770cea6..5f92f07 100644
--- a/src/main/resources/messages/pluginBundle_ar.properties
+++ b/src/main/resources/messages/pluginBundle_ar.properties
@@ -12,3 +12,5 @@ g_service=خدمة الجيل
g_router=توليد التوجيه
filter_salvo_api_list=مفتاح الإدخال فلتر
+
+copy=نسخة .
diff --git a/src/main/resources/messages/pluginBundle_de.properties b/src/main/resources/messages/pluginBundle_de.properties
index 9cd955b..c76ca69 100644
--- a/src/main/resources/messages/pluginBundle_de.properties
+++ b/src/main/resources/messages/pluginBundle_de.properties
@@ -12,3 +12,5 @@ g_service=Dienst generieren
g_router=Router generieren
filter_salvo_api_list=Eingabe von Schlüsselwörtern
+
+copy=Kopieren
diff --git a/src/main/resources/messages/pluginBundle_en.properties b/src/main/resources/messages/pluginBundle_en.properties
index d5220b2..99c22a8 100644
--- a/src/main/resources/messages/pluginBundle_en.properties
+++ b/src/main/resources/messages/pluginBundle_en.properties
@@ -12,3 +12,5 @@ g_service=Generate service
g_router=Generate router
filter_salvo_api_list=Input keyword filtering
+
+copy=Copy
diff --git a/src/main/resources/messages/pluginBundle_fr.properties b/src/main/resources/messages/pluginBundle_fr.properties
index 66189e8..72b1793 100644
--- a/src/main/resources/messages/pluginBundle_fr.properties
+++ b/src/main/resources/messages/pluginBundle_fr.properties
@@ -12,3 +12,5 @@ g_service=Générer un service
g_router=Générer un Router
filter_salvo_api_list=Entrer des mots - clés filtrer
+
+copy=Copie
diff --git a/src/main/resources/messages/pluginBundle_hk.properties b/src/main/resources/messages/pluginBundle_hk.properties
index e510ba1..8a79d37 100644
--- a/src/main/resources/messages/pluginBundle_hk.properties
+++ b/src/main/resources/messages/pluginBundle_hk.properties
@@ -12,3 +12,5 @@ g_service=生成service
g_router=生成router
filter_salvo_api_list=輸入關鍵字過濾
+
+copy=拷貝
diff --git a/src/main/resources/messages/pluginBundle_it.properties b/src/main/resources/messages/pluginBundle_it.properties
index 18f296a..93bd7d8 100644
--- a/src/main/resources/messages/pluginBundle_it.properties
+++ b/src/main/resources/messages/pluginBundle_it.properties
@@ -12,3 +12,5 @@ g_service=Genera servizio
g_router=Genera router
filter_salvo_api_list=Filtro parole chiave di input
+
+copy=Copia
diff --git a/src/main/resources/messages/pluginBundle_ja.properties b/src/main/resources/messages/pluginBundle_ja.properties
index 668802e..2c72be1 100644
--- a/src/main/resources/messages/pluginBundle_ja.properties
+++ b/src/main/resources/messages/pluginBundle_ja.properties
@@ -12,3 +12,5 @@ g_service=サービスの生成
g_router=routerを生成
filter_salvo_api_list=入力キーワードフィルタリング
+
+copy=コピー
diff --git a/src/main/resources/messages/pluginBundle_ko.properties b/src/main/resources/messages/pluginBundle_ko.properties
index 4d4079d..c89e597 100644
--- a/src/main/resources/messages/pluginBundle_ko.properties
+++ b/src/main/resources/messages/pluginBundle_ko.properties
@@ -12,3 +12,5 @@ g_service=서비스 생성
g_router=router 생성
filter_salvo_api_list=입력 키워드 필터링
+
+copy=복제
diff --git a/src/main/resources/messages/pluginBundle_nl.properties b/src/main/resources/messages/pluginBundle_nl.properties
index 928ea54..5b406f8 100644
--- a/src/main/resources/messages/pluginBundle_nl.properties
+++ b/src/main/resources/messages/pluginBundle_nl.properties
@@ -12,3 +12,5 @@ g_service=Dienst genereren
g_router=Router genereren
filter_salvo_api_list=Filtering van trefwoorden invoeren
+
+copy=Kopiëren
diff --git a/src/main/resources/messages/pluginBundle_pl.properties b/src/main/resources/messages/pluginBundle_pl.properties
index 93739c4..1138eb4 100644
--- a/src/main/resources/messages/pluginBundle_pl.properties
+++ b/src/main/resources/messages/pluginBundle_pl.properties
@@ -12,3 +12,5 @@ g_service=Generuj usługę
g_router=Generuj router
filter_salvo_api_list=Filtrowanie słów kluczowych
+
+copy=Kopiuj
diff --git a/src/main/resources/messages/pluginBundle_pt.properties b/src/main/resources/messages/pluginBundle_pt.properties
index 9801a93..d182d6e 100644
--- a/src/main/resources/messages/pluginBundle_pt.properties
+++ b/src/main/resources/messages/pluginBundle_pt.properties
@@ -12,3 +12,5 @@ g_service=Gerar serviço
g_router=Gerar o router
filter_salvo_api_list=Filtragem de palavras-chave de entrada
+
+copy=Copiar
diff --git a/src/main/resources/messages/pluginBundle_ru.properties b/src/main/resources/messages/pluginBundle_ru.properties
index 3d17b51..3d080d5 100644
--- a/src/main/resources/messages/pluginBundle_ru.properties
+++ b/src/main/resources/messages/pluginBundle_ru.properties
@@ -12,3 +12,5 @@ g_service=Создать службу
g_router=Создать router
filter_salvo_api_list=Введите фильтр ключевых слов
+
+copy=Копировать