From 82d0ade99b41c019b891babda13e7694d602db46 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=9E=97=E4=B8=87=E7=A8=8B?= <1498425439@qq.com>
Date: Thu, 27 Oct 2022 03:15:33 +0800
Subject: [PATCH] Compatible with old and new versions
---
build.gradle | 3 +
out/production/resources/META-INF/cs.xml | 5 -
out/production/resources/META-INF/go.xml | 5 -
out/production/resources/META-INF/java.xml | 6 -
out/production/resources/META-INF/js.xml | 5 -
out/production/resources/META-INF/kotlin.xml | 5 -
out/production/resources/META-INF/plugin.xml | 132 ---------
.../resources/META-INF/pluginIcon.svg | 12 -
out/production/resources/META-INF/python.xml | 5 -
out/production/resources/META-INF/sql.xml | 5 -
.../liveTemplates/show-comment-doc.xml | 254 ------------------
.../liveTemplates/show-comment-xml.xml | 12 -
.../plugin/show/CopyReferenceSimple.java | 7 +-
.../plugin/show/lang/SqlLangDoc.java | 19 +-
src/main/resources/META-INF/plugin.xml | 2 +-
15 files changed, 25 insertions(+), 452 deletions(-)
delete mode 100644 out/production/resources/META-INF/cs.xml
delete mode 100644 out/production/resources/META-INF/go.xml
delete mode 100644 out/production/resources/META-INF/java.xml
delete mode 100644 out/production/resources/META-INF/js.xml
delete mode 100644 out/production/resources/META-INF/kotlin.xml
delete mode 100644 out/production/resources/META-INF/plugin.xml
delete mode 100644 out/production/resources/META-INF/pluginIcon.svg
delete mode 100644 out/production/resources/META-INF/python.xml
delete mode 100644 out/production/resources/META-INF/sql.xml
delete mode 100644 out/production/resources/liveTemplates/show-comment-doc.xml
delete mode 100644 out/production/resources/liveTemplates/show-comment-xml.xml
diff --git a/build.gradle b/build.gradle
index 73cb8be..f85ab9e 100644
--- a/build.gradle
+++ b/build.gradle
@@ -25,10 +25,12 @@ intellij {
localPath = "/Applications/IntelliJ IDEA.app"
} else {
version = ideaVersion
+ // localPath = "D:/Program Files/JetBrains/IntelliJ IDEA 2021.2.2"
}
// see https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html#intellij-extension-plugins
plugins = [
'Pythonid:201.6668.121',
+ // 'Pythonid:212.5284.44',
]
if ('IC' == ideTypeStr || 'IU' == ideTypeStr) {
plugins.add('java')
@@ -38,6 +40,7 @@ intellij {
plugins.add('JavaScript')
plugins.add('com.intellij.database')
plugins.add('org.jetbrains.plugins.go:201.6668.60.126')
+ // plugins.add('org.jetbrains.plugins.go:212.5284.31')
}
}
diff --git a/out/production/resources/META-INF/cs.xml b/out/production/resources/META-INF/cs.xml
deleted file mode 100644
index 378e6e1..0000000
--- a/out/production/resources/META-INF/cs.xml
+++ /dev/null
@@ -1,5 +0,0 @@
-
-
-
-
-
\ No newline at end of file
diff --git a/out/production/resources/META-INF/go.xml b/out/production/resources/META-INF/go.xml
deleted file mode 100644
index 83c4946..0000000
--- a/out/production/resources/META-INF/go.xml
+++ /dev/null
@@ -1,5 +0,0 @@
-
-
-
-
-
\ No newline at end of file
diff --git a/out/production/resources/META-INF/java.xml b/out/production/resources/META-INF/java.xml
deleted file mode 100644
index 34293ac..0000000
--- a/out/production/resources/META-INF/java.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/out/production/resources/META-INF/js.xml b/out/production/resources/META-INF/js.xml
deleted file mode 100644
index 448e4da..0000000
--- a/out/production/resources/META-INF/js.xml
+++ /dev/null
@@ -1,5 +0,0 @@
-
-
-
-
-
\ No newline at end of file
diff --git a/out/production/resources/META-INF/kotlin.xml b/out/production/resources/META-INF/kotlin.xml
deleted file mode 100644
index 58051d5..0000000
--- a/out/production/resources/META-INF/kotlin.xml
+++ /dev/null
@@ -1,5 +0,0 @@
-
-
-
-
-
\ No newline at end of file
diff --git a/out/production/resources/META-INF/plugin.xml b/out/production/resources/META-INF/plugin.xml
deleted file mode 100644
index a9c4175..0000000
--- a/out/production/resources/META-INF/plugin.xml
+++ /dev/null
@@ -1,132 +0,0 @@
-
- io.github.linwancen.show-comment
- Show Comment
- 林万程
-
- English Notes:
-
-- 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 comments from External Conf for folder, resources, COBOL etc.
-
- Config: settings -> Tools -> // Show Comment Global/Project
-
-
-External Comment:
-Demo(GitHub)
-
-- Reload: Tools -> 🔄 // Reload External Comment
-
- path/[any][filename.]ext.tree.tsv // file and folder tree comment 📝 📁
-
- path/[any][filename.]ext.key.tsv // line keywords to split and comment
-
- path/[any][filename.]ext.doc.tsv // line words comment
-
- In path, "doc" can replace any, and can use % like in SQL, effect at previous layer when folder named -1
-
- The lines in key.tsv will be concatenated with `|` to regexp; longer str should in front; startWith `?` to exclude
-
- Chang tsv file in find pop window would not reload!
-
- The tsv conf file must could be search in "Go to File"(Ctrl + Shift + N)
-
-
-
-中文说明:
-
-- 在结构树显示 文档注释
-
- 在行末尾显示 文档注释
-
- 支持 "xx-类全名或简名.json" 文档注释与跳转到字段
-
- 支持 从配置文件获取外部注释用于文件夹、资源、COBOL 等
-
- 修改配置:设置 -> 工具 -> // Show Comment Global/Project
-
-
-外部注释:
-示例(Gitee)
-:比如你要给 .go 的文件配置文件注释可以放在相同目录或父目录的 xxx.go.tree.tsv 中
-
-- 重新加载:工具 -> "🔄 // Reload External Comment"
-
- path/[any][filename.]ext.tree.tsv // 文件(夹)注释 📝 📁
-
- path/[any][filename.]ext.key.tsv // 切割关键字与注释
-
- path/[any][filename.]ext.doc.tsv // 词注释
-
- key.tsv 的每一行将会用`|`连接起来形成正则表达式,较长的关键字应该放在前面,用 `?` 开头排除
-
- doc 文件夹可以替换任何一层文件夹,可以像 SQL 那样用 % 模糊匹配,文件夹名为 -1 时在上一层文件夹生效
-
- 在搜索弹出窗中修改 tsv 文件将不会被重加载
-
- tsv 配置文件必须能被搜索(Ctrl + Shift + N)
-
-
-如果对你有所帮助,别忘了给本项目
-GitHub
-主页一个 Start,您的支持是项目前进的动力。
- ]]>
-
-
- com.intellij.modules.java
- com.intellij.database
- JavaScript
- com.intellij.modules.python
- org.jetbrains.plugins.go
- org.jetbrains.kotlin
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/out/production/resources/META-INF/pluginIcon.svg b/out/production/resources/META-INF/pluginIcon.svg
deleted file mode 100644
index 22a4863..0000000
--- a/out/production/resources/META-INF/pluginIcon.svg
+++ /dev/null
@@ -1,12 +0,0 @@
-
\ No newline at end of file
diff --git a/out/production/resources/META-INF/python.xml b/out/production/resources/META-INF/python.xml
deleted file mode 100644
index 4f45f9c..0000000
--- a/out/production/resources/META-INF/python.xml
+++ /dev/null
@@ -1,5 +0,0 @@
-
-
-
-
-
\ No newline at end of file
diff --git a/out/production/resources/META-INF/sql.xml b/out/production/resources/META-INF/sql.xml
deleted file mode 100644
index 6045846..0000000
--- a/out/production/resources/META-INF/sql.xml
+++ /dev/null
@@ -1,5 +0,0 @@
-
-
-
-
-
\ No newline at end of file
diff --git a/out/production/resources/liveTemplates/show-comment-doc.xml b/out/production/resources/liveTemplates/show-comment-doc.xml
deleted file mode 100644
index ad25ff4..0000000
--- a/out/production/resources/liveTemplates/show-comment-doc.xml
+++ /dev/null
@@ -1,254 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/out/production/resources/liveTemplates/show-comment-xml.xml b/out/production/resources/liveTemplates/show-comment-xml.xml
deleted file mode 100644
index dbcddc9..0000000
--- a/out/production/resources/liveTemplates/show-comment-xml.xml
+++ /dev/null
@@ -1,12 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/src/main/java/io/github/linwancen/plugin/show/CopyReferenceSimple.java b/src/main/java/io/github/linwancen/plugin/show/CopyReferenceSimple.java
index 0e0b6f2..ab9d7b0 100644
--- a/src/main/java/io/github/linwancen/plugin/show/CopyReferenceSimple.java
+++ b/src/main/java/io/github/linwancen/plugin/show/CopyReferenceSimple.java
@@ -7,7 +7,6 @@ import com.intellij.openapi.editor.Document;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.project.Project;
import com.intellij.psi.PsiDocumentManager;
-import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -22,7 +21,7 @@ public class CopyReferenceSimple extends CopyReferenceAction {
super.update(e);
String tip = IdeBundle.message("copy.reference");
if (tip != null && tip.replace("\u001B", "").equals(e.getPresentation().getText())) {
- e.getPresentation().setText("Copy Class.Method/File:Line");
+ e.getPresentation().setText("Copy Class.Method / File:Line");
}
}
@@ -30,7 +29,9 @@ public class CopyReferenceSimple extends CopyReferenceAction {
@Nullable
@Override
- protected String getQualifiedName(@NotNull Editor editor, List elements) {
+ protected String getQualifiedName(@NotNull Editor editor, List elements) {
+ // because 2nd param is List in 2020.1 and List extends PsiElement> in new version
+ //noinspection unchecked
String qualifiedName = super.getQualifiedName(editor, elements);
if (qualifiedName == null) {
@NotNull Document document = editor.getDocument();
diff --git a/src/main/java/io/github/linwancen/plugin/show/lang/SqlLangDoc.java b/src/main/java/io/github/linwancen/plugin/show/lang/SqlLangDoc.java
index 585cc8f..16dcf22 100644
--- a/src/main/java/io/github/linwancen/plugin/show/lang/SqlLangDoc.java
+++ b/src/main/java/io/github/linwancen/plugin/show/lang/SqlLangDoc.java
@@ -2,7 +2,6 @@ package io.github.linwancen.plugin.show.lang;
import com.intellij.database.psi.DbElement;
import com.intellij.psi.PsiElement;
-import com.intellij.sql.SqlDocumentationProvider;
import com.intellij.sql.psi.SqlLanguage;
import com.intellij.sql.psi.SqlReferenceExpression;
import com.intellij.util.containers.JBIterable;
@@ -13,6 +12,8 @@ import io.github.linwancen.plugin.show.bean.LineInfo;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
+import java.lang.reflect.Method;
+
public class SqlLangDoc extends BaseLangDoc {
static {
@@ -34,8 +35,22 @@ public class SqlLangDoc extends BaseLangDoc {
protected @Nullable String refElementDoc(@NotNull T lineInfo,
@NotNull PsiElement ref) {
JBIterable relatedDbElements;
+ Class> clazz;
try {
- relatedDbElements = SqlDocumentationProvider.findRelatedDbElements(ref, false);
+ // new version new Class
+ clazz = Class.forName("com.intellij.sql.SqlNavigationUtils");
+ } catch (Throwable e) {
+ try {
+ // old version
+ clazz = Class.forName("com.intellij.sql.SqlDocumentationProvider");
+ } catch (Throwable e2) {
+ return null;
+ }
+ }
+ try {
+ Method method = clazz.getMethod("findRelatedDbElements", PsiElement.class, boolean.class);
+ //noinspection unchecked
+ relatedDbElements = (JBIterable) method.invoke(null, ref, false);
} catch (Throwable e) {
return null;
}
diff --git a/src/main/resources/META-INF/plugin.xml b/src/main/resources/META-INF/plugin.xml
index a7c6d90..1aaf070 100644
--- a/src/main/resources/META-INF/plugin.xml
+++ b/src/main/resources/META-INF/plugin.xml
@@ -117,7 +117,7 @@ Show doc comment at the Project view Tree, line End, json etc.
+ text="Copy Class.Method / File:Line">