From 7fa464855a88d477f1dcee8cdb0d55abf82458a7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=9E=97=E4=B8=87=E7=A8=8B?= <1498425439@qq.com>
Date: Tue, 9 Aug 2022 00:41:23 +0800
Subject: [PATCH] =?UTF-8?q?1.22=20Chang=20PopupMenu=20And=20Add=20Copy=20C?=
=?UTF-8?q?lassName.MethodName=20|=20=E8=B0=83=E6=95=B4=20=E5=8F=B3?=
=?UTF-8?q?=E9=94=AE=E8=8F=9C=E5=8D=95=20=E5=B9=B6=E5=A2=9E=E5=8A=A0?=
=?UTF-8?q?=E8=8F=9C=E5=8D=95=E9=A1=B9=EF=BC=9A=E5=A4=8D=E5=88=B6=20?=
=?UTF-8?q?=E7=B1=BB=E5=90=8D.=E6=96=B9=E6=B3=95=E5=90=8D=20Fixed=20#8?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
README.md | 18 ++++-----
build.gradle | 12 +++---
.../plugin/show/CopyReferenceSimple.java | 38 +++++++++++++++++++
src/main/resources/META-INF/plugin.xml | 16 ++++++--
4 files changed, 65 insertions(+), 19 deletions(-)
create mode 100644 src/main/java/io/github/linwancen/plugin/show/CopyReferenceSimple.java
diff --git a/README.md b/README.md
index 0bb185e..925522f 100644
--- a/README.md
+++ b/README.md
@@ -11,7 +11,7 @@ Thanks JetBrains Licenses for Open Source.
- Show javadoc comments at the Project view Tree structure
- Show javadoc comments at the end-of-line
-
- Show javadoc comments at "xx ClassNameOrSimpleName.json" and jump to field
+
- Show javadoc comments at "xx-ClassNameOrSimpleName.json" and jump to field
- Show comments from External Conf for folder, resources, COBOL etc.
- Config: settings -> Tools -> // Show Comment Global/Project
@@ -34,7 +34,7 @@ Thanks JetBrains Licenses for Open Source.
- 在结构树显示 文档注释
- 在行末尾显示 文档注释
-
- 支持 "xx 类全名或简名.json" 文档注释与跳转到字段
+
- 支持 "xx-类全名或简名.json" 文档注释与跳转到字段
- 支持 从配置文件获取外部注释用于文件夹、资源、COBOL 等
- 修改配置:设置 -> 工具 -> // Show Comment Global/Project
@@ -58,8 +58,7 @@ Thanks JetBrains Licenses for Open Source.
English Change Notes:
-- 2.01 Add line-end-comment show before doc for `isA(xxx)` and `a.set(b.get)`
-
- 2.00 ★★ Support all JetBrains IDE and Golang, Python, JavaScript
+
- 1.22 Add PopupMenu Copy ClassName.MethodName
- 1.21 Add line-end-comment default skip only English when system lang is not `en`
- 1.20 Add get doc first sentence checkbox
- 1.19 Add supper doc at @Override, support doc tag like @author
@@ -72,8 +71,8 @@ Thanks JetBrains Licenses for Open Source.
- 1.12 ★ External Comment for COBOL etc
- 1.11 Add json key jump to field
- 1.10 Add project-view-tree-comment for package from parent or other project
-
- 1.9 Add project-view-tree-comment for "xx ClassNameOrSimpleName.json" and SPI file
-
- 1.8 ★ line-end-comment for "xx ClassNameOrSimpleName.json"
+
- 1.9 Add project-view-tree-comment for "xx-ClassNameOrSimpleName.json" and SPI file
+
- 1.8 ★ line-end-comment for "xx-ClassNameOrSimpleName.json"
- 1.7 Add line-end-comment setting for prefix and count
- 1.6 Add line-end-comment independent switch for call, new, ref
- 1.5 Add line-end-comment find next loop when none
@@ -85,8 +84,7 @@ Thanks JetBrains Licenses for Open Source.
中文更新说明:
-- 2.01 增加 行末注释 `isA(xxx)` 和 `a.set(b.get)` 显示前一个注释
-
- 2.00 ★★ 支持所有 JetBrains 软件和 Golang, Python, JavaScript
+
- 1.22 增加 右键菜单 复制 类名.方法名
- 1.21 增加 行末注释 系统语言非英文时 默认 忽略纯英文
- 1.20 增加 获取第一句注释选项
- 1.19 增加 @Override 显示父方法注释,支持 @author 等注释标签
@@ -99,8 +97,8 @@ Thanks JetBrains Licenses for Open Source.
- 1.12 ★ 外部注释用于 COBOL 等
- 1.11 增加 json 跳转到字段
- 1.10 增加 在父包和其他项目的包中获取 项目导航栏注释
-
- 1.9 增加 "xx 类全名或简名.json" 和 SPI 项目导航栏注释
-
- 1.8 ★ "xx 类全名或简名.json" 行末注释
+
- 1.9 增加 "xx-类全名或简名.json" 和 SPI 项目导航栏注释
+
- 1.8 ★ "xx-类全名或简名.json" 行末注释
- 1.7 增加 行末注释前缀和对象数设置
- 1.6 增加 行末调用,new,引用注释独立开关
- 1.5 增加 没有注释时循环查找下一个对象
diff --git a/build.gradle b/build.gradle
index 9be2b42..8e9677e 100644
--- a/build.gradle
+++ b/build.gradle
@@ -4,7 +4,7 @@ plugins {
}
group 'io.github.linwancen'
-version '1.21.0.' + (new Date().format('yyyy.MM.dd_HH.mm'))
+version '1.22.0.' + (new Date().format('yyyy.MM.dd_HH.mm'))
apply plugin: 'java'
@@ -39,6 +39,7 @@ patchPluginXml {
changeNotes = """
English Change Notes:
+- 1.22 Add PopupMenu Copy ClassName.MethodName
- 1.21 Add line-end-comment default skip only English when system lang is not `en`
- 1.20 Add get doc first sentence checkbox
- 1.19 Add supper doc at @Override, support doc tag like @author
@@ -51,8 +52,8 @@ patchPluginXml {
- 1.12 ★ External Comment for COBOL etc
- 1.11 Add json key jump to field
- 1.10 Add project-view-tree-comment for package from parent or other project
-
- 1.9 Add project-view-tree-comment for "xx ClassNameOrSimpleName.json" and SPI file
-
- 1.8 ★ line-end-comment for "xx ClassNameOrSimpleName.json"
+
- 1.9 Add project-view-tree-comment for "xx-ClassNameOrSimpleName.json" and SPI file
+
- 1.8 ★ line-end-comment for "xx-ClassNameOrSimpleName.json"
- 1.7 Add line-end-comment setting for prefix and count
- 1.6 Add line-end-comment independent switch for call, new, ref
- 1.5 Add line-end-comment find next loop when none
@@ -64,6 +65,7 @@ patchPluginXml {
中文更新说明:
+- 1.22 增加 右键菜单 复制 类名.方法名
- 1.21 增加 行末注释 系统语言非英文时 默认 忽略纯英文
- 1.20 增加 获取第一句注释选项
- 1.19 增加 @Override 显示父方法注释,支持 @author 等注释标签
@@ -76,8 +78,8 @@ patchPluginXml {
- 1.12 ★ 外部注释用于 COBOL 等
- 1.11 增加 json 跳转到字段
- 1.10 增加 在父包和其他项目的包中获取 项目导航栏注释
-
- 1.9 增加 "xx 类全名或简名.json" 和 SPI 项目导航栏注释
-
- 1.8 ★ "xx 类全名或简名.json" 行末注释
+
- 1.9 增加 "xx-类全名或简名.json" 和 SPI 项目导航栏注释
+
- 1.8 ★ "xx-类全名或简名.json" 行末注释
- 1.7 增加 行末注释前缀和对象数设置
- 1.6 增加 行末调用,new,引用注释独立开关
- 1.5 增加 没有注释时循环查找下一个对象
diff --git a/src/main/java/io/github/linwancen/plugin/show/CopyReferenceSimple.java b/src/main/java/io/github/linwancen/plugin/show/CopyReferenceSimple.java
new file mode 100644
index 0000000..6990fed
--- /dev/null
+++ b/src/main/java/io/github/linwancen/plugin/show/CopyReferenceSimple.java
@@ -0,0 +1,38 @@
+package io.github.linwancen.plugin.show;
+
+import com.intellij.ide.IdeBundle;
+import com.intellij.ide.actions.CopyReferenceAction;
+import com.intellij.openapi.actionSystem.AnActionEvent;
+import com.intellij.openapi.editor.Editor;
+import com.intellij.psi.PsiElement;
+import org.jetbrains.annotations.NotNull;
+
+import java.util.List;
+import java.util.regex.Pattern;
+
+public class CopyReferenceSimple extends CopyReferenceAction {
+
+ @Override
+ public void update(@NotNull AnActionEvent e) {
+ super.update(e);
+ String tip = IdeBundle.message("copy.reference");
+ if (tip != null && tip.replace("\u001B", "").equals(e.getPresentation().getText())) {
+ e.getPresentation().setText("Copy ClassName.MethodName");
+ }
+ }
+
+ private static final Pattern QUALIFIED_PATTERN = Pattern.compile("[\\w.]+\\.");
+
+ protected String getQualifiedName(Editor editor, List elements) {
+ String qualifiedName = super.getQualifiedName(editor, elements);
+ int i = qualifiedName.indexOf("(");
+ if (i > 0) {
+ return QUALIFIED_PATTERN.matcher(qualifiedName).replaceAll("").replace('#', '.');
+ }
+ i = qualifiedName.lastIndexOf(".");
+ if (i > 0) {
+ return qualifiedName.substring(i + 1).replace('#', '.');
+ }
+ return qualifiedName;
+ }
+}
diff --git a/src/main/resources/META-INF/plugin.xml b/src/main/resources/META-INF/plugin.xml
index 184098e..82dcada 100644
--- a/src/main/resources/META-INF/plugin.xml
+++ b/src/main/resources/META-INF/plugin.xml
@@ -8,7 +8,7 @@
- Show javadoc comments at the Project view Tree structure
- Show javadoc comments at the end-of-line
-
- Show javadoc comments at "xx ClassNameOrSimpleName.json" and jump to field
+
- Show javadoc comments at "xx-ClassNameOrSimpleName.json" and jump to field
- Show comments from External Conf for folder, resources, COBOL etc.
- Config: settings -> Tools -> // Show Comment Global/Project
@@ -31,7 +31,7 @@
- 在结构树显示 文档注释
- 在行末尾显示 文档注释
-
- 支持 "xx 类全名或简名.json" 文档注释与跳转到字段
+
- 支持 "xx-类全名或简名.json" 文档注释与跳转到字段
- 支持 从配置文件获取外部注释用于文件夹、资源、COBOL 等
- 修改配置:设置 -> 工具 -> // Show Comment Global/Project
@@ -106,13 +106,21 @@
id="io.github.linwancen.plugin.show.LineEndCopy"
class="io.github.linwancen.plugin.show.LineEndCopy"
text="// Copy With Line Comment">
-
+
+
+
+
-
+
\ No newline at end of file