feat: 2.24 Maven pom.xml ${} doc

This commit is contained in:
林万程
2025-07-02 07:42:19 +08:00
parent 9b01bcb50c
commit 66b6be52d5
9 changed files with 123 additions and 7 deletions

View File

@@ -4,7 +4,7 @@ plugins {
}
group 'io.github.linwancen'
version '2.23.0.' + (new Date().format('yyyy.MM.dd_HH.mm'))
version '2.24.0.' + (new Date().format('yyyy.MM.dd_HH.mm'))
patchPluginXml {
// The performance of 2019.3 has been greatly improved.
@@ -15,6 +15,7 @@ patchPluginXml {
changeNotes = """
<h2>English Change Notes:</h2>
<ul>
<li>2.24 Add line-end-comment Maven pom.xml \${} doc
<li>2.23 Add line-end-comment kotlin anno doc
<li>2.22 Add project-view-tree ollama models blobs comment from manifests
<li>2.21 Add project-view-tree use JS/TS/Vue "export default" doc for tree doc
@@ -67,6 +68,7 @@ patchPluginXml {
<h2>中文更新说明:</h2>
<ul>
<li>2.24 增加 行末注释 Maven pom.xml \${} 注释
<li>2.23 增加 行末注释 kotlin 注解注释
<li>2.22 增加 文件树注释 ollama models 文件夹从 manifests 获取 blobs 文件注释
<li>2.21 增加 文件树注释 用 JS/TS/Vue "export default" 注释当文件注释
@@ -151,6 +153,7 @@ intellij {
]
if ('IC' == ideTypeStr || 'IU' == ideTypeStr) {
plugins.add('java')
plugins.add('org.jetbrains.idea.maven')
plugins.add('org.jetbrains.kotlin')
plugins.add('org.intellij.groovy')
plugins.add('org.intellij.scala:2020.1.43')

View File

@@ -0,0 +1,49 @@
package io.github.linwancen.plugin.show.java;
import com.intellij.psi.FileViewProvider;
import com.intellij.psi.PsiElement;
import io.github.linwancen.plugin.show.bean.LineInfo;
import io.github.linwancen.plugin.show.lang.XmlLangDoc;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.idea.maven.dom.MavenDomUtil;
import org.jetbrains.idea.maven.dom.MavenPropertyResolver;
import org.jetbrains.idea.maven.dom.model.MavenDomProjectModel;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class MavenLangDoc extends XmlLangDoc {
Pattern PARAM_PATTERN = Pattern.compile("\\$\\{[^}]++}");
@Nullable
@Override
public String findRefDoc(@NotNull LineInfo info, @NotNull FileViewProvider viewProvider,
@NotNull PsiElement element) {
if (!"pom.xml".equals(info.file.getName()) || !info.text.contains("$")) {
return null;
}
MavenDomProjectModel mdm = MavenDomUtil.getMavenDomModel(element.getContainingFile(), MavenDomProjectModel.class);
if (mdm == null) {
return null;
}
List<String> list = new ArrayList<>();
Matcher m = PARAM_PATTERN.matcher(info.text);
while (m.find()) {
String s = m.group();
String v;
try {
v = MavenPropertyResolver.resolve(s, mdm);
} catch (Exception ignored) {
v = "";
}
list.add(v);
}
if (list.isEmpty()) {
return null;
}
return String.join(" | ", list);
}
}

View File

@@ -0,0 +1,45 @@
package io.github.linwancen.plugin.show.lang;
import com.intellij.lang.xml.XMLLanguage;
import com.intellij.openapi.extensions.ExtensionPointName;
import com.intellij.psi.FileViewProvider;
import com.intellij.psi.PsiElement;
import com.intellij.psi.xml.XmlAttribute;
import com.intellij.psi.xml.XmlTag;
import io.github.linwancen.plugin.show.bean.LineInfo;
import io.github.linwancen.plugin.show.lang.base.BaseLangDoc;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.List;
public class XmlLangDoc extends BaseLangDoc {
static {
LANG_DOC_MAP.put(XMLLanguage.INSTANCE.getID(), new XmlLangDoc());
}
@Override
public @NotNull List<Class<? extends PsiElement>> getRefClass() {
return List.of(XmlAttribute.class, XmlTag.class);
}
@Override
public boolean show(@NotNull LineInfo info) {
return true;
}
@Nullable
@Override
public String findRefDoc(@NotNull LineInfo info, @NotNull FileViewProvider viewProvider, @NotNull PsiElement element) {
ExtensionPointName<XmlLangDoc> epn = ExtensionPointName.create("io.github.linwancen.show-comment.xmlLangDoc");
List<XmlLangDoc> extensionList = epn.getExtensionList();
for (XmlLangDoc xmlLangDoc : extensionList) {
String doc = xmlLangDoc.findRefDoc(info, viewProvider, element);
if (doc != null && !doc.trim().isEmpty()) {
return doc;
}
}
return null;
}
}

View File

@@ -42,6 +42,7 @@ public abstract class AbstractSettingsComponent {
protected JPanel commonPanel() {
return FormBuilder.createFormBuilder()
.addComponent(lineEndPanel(), 1)
.addComponent(webPanel(), 1)
.addComponent(treePanel(), 1)
.getPanel();
}
@@ -58,11 +59,6 @@ public abstract class AbstractSettingsComponent {
.addSeparator()
.addLabeledComponent(new JBLabel(ShowBundle.message("comment.include.regexp")), docInclude, 1, true)
.addLabeledComponent(new JBLabel(ShowBundle.message("comment.exclude.regexp")), docExclude, 1, true)
.addSeparator()
.addLabeledComponent(new JBLabel(ShowBundle.message("tag.include.regexp")), tagInclude, 1, true)
.addLabeledComponent(new JBLabel(ShowBundle.message("tag.exclude.regexp")), tagExclude, 1, true)
.addLabeledComponent(new JBLabel(ShowBundle.message("attr.include.regexp")), attrInclude, 1, true)
.addLabeledComponent(new JBLabel(ShowBundle.message("attr.exclude.regexp")), attrExclude, 1, true)
.addSeparator();
Border border = docGet.getBorder();
annoDoc.setBorder(border);
@@ -77,6 +73,18 @@ public abstract class AbstractSettingsComponent {
return panel;
}
@NotNull
private JPanel webPanel() {
JPanel panel = FormBuilder.createFormBuilder()
.addLabeledComponent(new JBLabel(ShowBundle.message("tag.include.regexp")), tagInclude, 1, true)
.addLabeledComponent(new JBLabel(ShowBundle.message("tag.exclude.regexp")), tagExclude, 1, true)
.addLabeledComponent(new JBLabel(ShowBundle.message("attr.include.regexp")), attrInclude, 1, true)
.addLabeledComponent(new JBLabel(ShowBundle.message("attr.exclude.regexp")), attrExclude, 1, true)
.getPanel();
panel.setBorder(IdeBorderFactory.createTitledBorder(ShowBundle.message("web.comment")));
return panel;
}
@NotNull
private JPanel treePanel() {
@NotNull JPanel dirLabel = JPanelFactory.of(dirDocEffect, new JBLabel(ShowBundle.message("dir.doc.regexp")));

View File

@@ -1,6 +1,7 @@
<idea-plugin>
<extensions defaultExtensionNs="com.intellij">
<psi.referenceContributor implementation="io.github.linwancen.plugin.show.java.JsonJumpJava"/>
<psi.referenceContributor implementation="io.github.linwancen.plugin.show.java.JsonJumpJava" language="JSON"/>
<psi.referenceContributor implementation="io.github.linwancen.plugin.show.java.JsonJumpJava" language="JSON5"/>
<editor.linePainter implementation="io.github.linwancen.plugin.show.java.JavaLangDoc"/>
</extensions>
</idea-plugin>

View File

@@ -0,0 +1,5 @@
<idea-plugin>
<extensions defaultExtensionNs="io.github.linwancen.show-comment">
<xmlLangDoc implementation="io.github.linwancen.plugin.show.java.MavenLangDoc"/>
</extensions>
</idea-plugin>

View File

@@ -123,6 +123,7 @@ Show doc comment in the Project view Tree, line End, json, other
on how to target different products -->
<depends>com.intellij.modules.platform</depends>
<depends optional="true" config-file="java.xml">com.intellij.modules.java</depends>
<depends optional="true" config-file="maven.xml">org.jetbrains.idea.maven</depends>
<depends optional="true" config-file="kotlin.xml">org.jetbrains.kotlin</depends>
<depends optional="true" config-file="groovy.xml">org.intellij.groovy</depends>
<depends optional="true" config-file="scala.xml">org.intellij.scala</depends>
@@ -163,6 +164,7 @@ Show doc comment in the Project view Tree, line End, json, other
</projectListeners>
<extensionPoints>
<extensionPoint name="xmlLangDoc" dynamic="true" interface="io.github.linwancen.plugin.show.lang.XmlLangDoc"/>
<extensionPoint name="fileLoader" dynamic="true" interface="io.github.linwancen.plugin.show.ext.listener.FileLoader"/>
</extensionPoints>
<extensions defaultExtensionNs="io.github.linwancen.show-comment">
@@ -172,6 +174,7 @@ Show doc comment in the Project view Tree, line End, json, other
<extensions defaultExtensionNs="com.intellij">
<editor.linePainter implementation="io.github.linwancen.plugin.show.LineEnd"/>
<editor.linePainter implementation="io.github.linwancen.plugin.show.lang.XmlLangDoc"/>
<projectViewNodeDecorator implementation="io.github.linwancen.plugin.show.Tree"/>
<defaultLiveTemplates file="/liveTemplates/show-comment-_.xml"/>
<defaultLiveTemplates file="/liveTemplates/show-comment-doc.xml"/>

View File

@@ -23,6 +23,7 @@ text.color.json=json text color:
prefix=prefix:
line.end.comment=Line End Comment
web.comment=Web Comment
tree.comment=Tree Comment
regexp.tip=Separated by '|' (Regexp), use '' to include all or exclude none.
sign.include.regexp=className#memberName include Regexp:

View File

@@ -23,6 +23,7 @@ text.color.json=json \u6587\u672C\u989C\u8272\uFF1A
prefix=\u524D\u7F00\uFF1A
line.end.comment=\u884C\u672B\u6CE8\u91CA
web.comment=Web \u6CE8\u91CA
tree.comment=\u6811\u6CE8\u91CA
regexp.tip=| \u5206\u9694 (\u6B63\u5219), \u7A7A\u5B57\u7B26\u4E32\u4EE3\u8868\u5305\u62EC\u6240\u6709\u6216\u4E0D\u6392\u9664
sign.include.regexp=\u7C7B#\u65B9\u6CD5 \u5305\u542B \u6B63\u5219\uFF1A