1.19 support doc tag like @author | 支持 @author 等注释标签
This commit is contained in:
@@ -56,6 +56,7 @@ Thanks JetBrains Licenses for Open Source.
|
|||||||
|
|
||||||
<h2>English Change Notes:</h2>
|
<h2>English Change Notes:</h2>
|
||||||
<ul>
|
<ul>
|
||||||
|
<li>1.19 Add supper doc at @Override, support doc tag like @author
|
||||||
<li>1.18 Add External Comment effect at previous layer when folder named -1
|
<li>1.18 Add External Comment effect at previous layer when folder named -1
|
||||||
<li>1.17 Add line-end-comment skip doc text or class/member name by regexp
|
<li>1.17 Add line-end-comment skip doc text or class/member name by regexp
|
||||||
<li>1.16 Add line-end-comment skip when comments have been added
|
<li>1.16 Add line-end-comment skip when comments have been added
|
||||||
@@ -78,6 +79,7 @@ Thanks JetBrains Licenses for Open Source.
|
|||||||
|
|
||||||
<h2>中文更新说明:</h2>
|
<h2>中文更新说明:</h2>
|
||||||
<ul>
|
<ul>
|
||||||
|
<li>1.19 增加 @Override 显示父方法注释,支持 @author 等注释标签
|
||||||
<li>1.18 增加 外部注释 文件夹名为 -1 时配置在上一层文件夹生效
|
<li>1.18 增加 外部注释 文件夹名为 -1 时配置在上一层文件夹生效
|
||||||
<li>1.17 增加 行末注释 根据正则表达式跳过指定注释文本或类成员名字的注释
|
<li>1.17 增加 行末注释 根据正则表达式跳过指定注释文本或类成员名字的注释
|
||||||
<li>1.16 增加 行末注释 已经添加行末注释时跳过
|
<li>1.16 增加 行末注释 已经添加行末注释时跳过
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
group 'io.github.linwancen'
|
group 'io.github.linwancen'
|
||||||
version '1.18.0.' + (new Date().format('yyyy.MM.dd_HH.mm'))
|
version '1.19.0.' + (new Date().format('yyyy.MM.dd_HH.mm'))
|
||||||
|
|
||||||
apply plugin: 'java'
|
apply plugin: 'java'
|
||||||
|
|
||||||
@@ -39,6 +39,7 @@ patchPluginXml {
|
|||||||
changeNotes = """
|
changeNotes = """
|
||||||
<h2>English Change Notes:</h2>
|
<h2>English Change Notes:</h2>
|
||||||
<ul>
|
<ul>
|
||||||
|
<li>1.19 Add supper doc at @Override, support doc tag like @author
|
||||||
<li>1.18 Add External Comment effect at previous layer when folder named -1
|
<li>1.18 Add External Comment effect at previous layer when folder named -1
|
||||||
<li>1.17 Add line-end-comment skip doc text or class/member name by regexp
|
<li>1.17 Add line-end-comment skip doc text or class/member name by regexp
|
||||||
<li>1.16 Add line-end-comment skip when comments have been added
|
<li>1.16 Add line-end-comment skip when comments have been added
|
||||||
@@ -61,6 +62,7 @@ patchPluginXml {
|
|||||||
|
|
||||||
<h2>中文更新说明:</h2>
|
<h2>中文更新说明:</h2>
|
||||||
<ul>
|
<ul>
|
||||||
|
<li>1.19 增加 @Override 显示父方法注释,支持 @author 等注释标签
|
||||||
<li>1.18 增加 外部注释 文件夹名为 -1 时配置在上一层文件夹生效
|
<li>1.18 增加 外部注释 文件夹名为 -1 时配置在上一层文件夹生效
|
||||||
<li>1.17 增加 行末注释 根据正则表达式跳过指定注释文本或类成员名字的注释
|
<li>1.17 增加 行末注释 根据正则表达式跳过指定注释文本或类成员名字的注释
|
||||||
<li>1.16 增加 行末注释 已经添加行末注释时跳过
|
<li>1.16 增加 行末注释 已经添加行末注释时跳过
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ public class Tree implements ProjectViewNodeDecorator {
|
|||||||
if (docComment == null) {
|
if (docComment == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return PsiDocToStrDoc.text(docComment);
|
return PsiDocToStrDoc.text(docComment, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
package io.github.linwancen.plugin.show.doc;
|
package io.github.linwancen.plugin.show.doc;
|
||||||
|
|
||||||
import com.intellij.psi.PsiElement;
|
import com.intellij.psi.PsiElement;
|
||||||
import com.intellij.psi.javadoc.PsiDocComment;
|
import com.intellij.psi.PsiWhiteSpace;
|
||||||
import com.intellij.psi.javadoc.PsiDocToken;
|
import com.intellij.psi.javadoc.*;
|
||||||
import com.intellij.psi.javadoc.PsiInlineDocTag;
|
|
||||||
import io.github.linwancen.plugin.show.settings.AppSettingsState;
|
import io.github.linwancen.plugin.show.settings.AppSettingsState;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
@@ -14,7 +14,7 @@ public class PsiDocToStrDoc {
|
|||||||
private PsiDocToStrDoc() {}
|
private PsiDocToStrDoc() {}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public static String text(@Nullable PsiDocComment psiDocComment) {
|
public static String text(@Nullable PsiDocComment psiDocComment, boolean isTree) {
|
||||||
if (psiDocComment == null) {
|
if (psiDocComment == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -32,33 +32,61 @@ public class PsiDocToStrDoc {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
StringBuilder tags = tags(psiDocComment, isTree, appSettings);
|
||||||
|
if (tags.length() > 0) {
|
||||||
|
if (sb.length() > 0) {
|
||||||
|
sb.append("@ ");
|
||||||
|
}
|
||||||
|
sb.append(tags);
|
||||||
|
}
|
||||||
if (sb.length() == 0) {
|
if (sb.length() == 0) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
private static StringBuilder tags(@NotNull PsiDocComment psiDocComment, boolean isTree,
|
||||||
|
AppSettingsState appSettings) {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
PsiDocTag[] tags = psiDocComment.getTags();
|
||||||
|
for (PsiDocTag tag : tags) {
|
||||||
|
String name = tag.getName();
|
||||||
|
if (isTree ? appSettings.treeTags.contains(name) : appSettings.lineTags.contains(name)) {
|
||||||
|
// @see @param should use getDataElements()
|
||||||
|
PsiDocTagValue value = tag.getValueElement();
|
||||||
|
if (value != null) {
|
||||||
|
addHtml(sb, value.getText());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return sb;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return is new line
|
||||||
|
*/
|
||||||
private static boolean appendElementText(StringBuilder sb, PsiElement element) {
|
private static boolean appendElementText(StringBuilder sb, PsiElement element) {
|
||||||
if (element instanceof PsiDocToken) {
|
if (element instanceof PsiDocToken) {
|
||||||
PsiDocToken psiDocToken = (PsiDocToken) element;
|
PsiDocToken psiDocToken = (PsiDocToken) element;
|
||||||
sb.append(deleteHtml(psiDocToken.getText()));
|
addHtml(sb, psiDocToken.getText());
|
||||||
sb.append(" ");
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
if (element instanceof PsiInlineDocTag) {
|
if (element instanceof PsiInlineDocTag) {
|
||||||
PsiInlineDocTag psiInlineDocTag = (PsiInlineDocTag) element;
|
PsiInlineDocTag psiInlineDocTag = (PsiInlineDocTag) element;
|
||||||
PsiElement[] children = psiInlineDocTag.getChildren();
|
PsiElement[] children = psiInlineDocTag.getChildren();
|
||||||
if (children.length > 2) {
|
if (children.length > 3) {
|
||||||
sb.append(deleteHtml(children[2].getText()));
|
addHtml(sb, children[3].getText());
|
||||||
sb.append(" ");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return element instanceof PsiWhiteSpace && sb.length() > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final Pattern HTML_PATTERN = Pattern.compile("<[^>]++>");
|
private static final Pattern HTML_PATTERN = Pattern.compile("<[^>]++>");
|
||||||
|
|
||||||
private static String deleteHtml(String s) {
|
private static void addHtml(StringBuilder sb, String s) {
|
||||||
return HTML_PATTERN.matcher(s.trim()).replaceAll("");
|
String deleteHtml = HTML_PATTERN.matcher(s.trim()).replaceAll("");
|
||||||
|
if (deleteHtml.length() > 0) {
|
||||||
|
sb.append(deleteHtml).append(" ");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ public class FileViewToDocStrUtils {
|
|||||||
PsiDocComment docComment = setting.findElementRightToLeft
|
PsiDocComment docComment = setting.findElementRightToLeft
|
||||||
? FileViewToPsiDocRightToLeft.rightDoc(viewProvider, startOffset, endOffset)
|
? FileViewToPsiDocRightToLeft.rightDoc(viewProvider, startOffset, endOffset)
|
||||||
: FileViewToPsiDocLeftToRight.leftDoc(viewProvider, document, startOffset, endOffset);
|
: FileViewToPsiDocLeftToRight.leftDoc(viewProvider, document, startOffset, endOffset);
|
||||||
String strDoc = PsiDocToStrDoc.text(docComment);
|
String strDoc = PsiDocToStrDoc.text(docComment, false);
|
||||||
if (strDoc == null) {
|
if (strDoc == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,7 +15,9 @@ public class AppSettingsComponent extends AbstractSettingsComponent {
|
|||||||
|
|
||||||
private final JPanel myMainPanel;
|
private final JPanel myMainPanel;
|
||||||
private final JBCheckBox showTreeComment = new JBCheckBox("Show tree comment ");
|
private final JBCheckBox showTreeComment = new JBCheckBox("Show tree comment ");
|
||||||
|
private final JBTextField treeTags = new JBTextField();
|
||||||
private final JBCheckBox showLineEndComment = new JBCheckBox("Show line end comment ");
|
private final JBCheckBox showLineEndComment = new JBCheckBox("Show line end comment ");
|
||||||
|
private final JBTextField lineTags = new JBTextField();
|
||||||
private final JBCheckBox fromCall = new JBCheckBox("call ");
|
private final JBCheckBox fromCall = new JBCheckBox("call ");
|
||||||
private final JBCheckBox fromNew = new JBCheckBox("new ");
|
private final JBCheckBox fromNew = new JBCheckBox("new ");
|
||||||
private final JBCheckBox fromRef = new JBCheckBox("ref ");
|
private final JBCheckBox fromRef = new JBCheckBox("ref ");
|
||||||
@@ -26,8 +28,8 @@ public class AppSettingsComponent extends AbstractSettingsComponent {
|
|||||||
private final ColorPanel lineEndColor = new ColorPanel();
|
private final ColorPanel lineEndColor = new ColorPanel();
|
||||||
private final ColorPanel lineEndJsonColor = new ColorPanel();
|
private final ColorPanel lineEndJsonColor = new ColorPanel();
|
||||||
private final JBCheckBox findElementRightToLeft = new JBCheckBox("Find element right to left");
|
private final JBCheckBox findElementRightToLeft = new JBCheckBox("Find element right to left");
|
||||||
protected final JBTextField lineEndPrefix = new JBTextField();
|
private final JBTextField lineEndPrefix = new JBTextField();
|
||||||
protected final JBTextField lineEndCount = new JBTextField();
|
private final JBTextField lineEndCount = new JBTextField();
|
||||||
|
|
||||||
public AppSettingsComponent() {
|
public AppSettingsComponent() {
|
||||||
myMainPanel = FormBuilder.createFormBuilder()
|
myMainPanel = FormBuilder.createFormBuilder()
|
||||||
@@ -42,6 +44,8 @@ public class AppSettingsComponent extends AbstractSettingsComponent {
|
|||||||
JPanel comment = FormBuilder.createFormBuilder()
|
JPanel comment = FormBuilder.createFormBuilder()
|
||||||
.addComponent(showTreeComment, 1)
|
.addComponent(showTreeComment, 1)
|
||||||
.addComponent(showLineEndComment, 1)
|
.addComponent(showLineEndComment, 1)
|
||||||
|
.addLabeledComponent(new JBLabel("tree tags"), treeTags, 1, true)
|
||||||
|
.addLabeledComponent(new JBLabel("line tags"), lineTags, 1, true)
|
||||||
.getPanel();
|
.getPanel();
|
||||||
comment.setBorder(IdeBorderFactory.createTitledBorder("Show"));
|
comment.setBorder(IdeBorderFactory.createTitledBorder("Show"));
|
||||||
return comment;
|
return comment;
|
||||||
@@ -81,6 +85,15 @@ public class AppSettingsComponent extends AbstractSettingsComponent {
|
|||||||
showTreeComment.setSelected(newStatus);
|
showTreeComment.setSelected(newStatus);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public String getTreeTags() {
|
||||||
|
return treeTags.getText();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTreeTags(@NotNull String newText) {
|
||||||
|
treeTags.setText(newText);
|
||||||
|
}
|
||||||
|
|
||||||
public boolean getShowLineEndComment() {
|
public boolean getShowLineEndComment() {
|
||||||
return showLineEndComment.isSelected();
|
return showLineEndComment.isSelected();
|
||||||
}
|
}
|
||||||
@@ -89,6 +102,15 @@ public class AppSettingsComponent extends AbstractSettingsComponent {
|
|||||||
showLineEndComment.setSelected(newStatus);
|
showLineEndComment.setSelected(newStatus);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public String getLineTags() {
|
||||||
|
return lineTags.getText();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLineTags(@NotNull String newText) {
|
||||||
|
lineTags.setText(newText);
|
||||||
|
}
|
||||||
|
|
||||||
public boolean getFromCall() {
|
public boolean getFromCall() {
|
||||||
return fromCall.isSelected();
|
return fromCall.isSelected();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,7 +32,9 @@ public class AppSettingsConfigurable implements Configurable {
|
|||||||
public boolean isModified() {
|
public boolean isModified() {
|
||||||
AppSettingsState settings = AppSettingsState.getInstance();
|
AppSettingsState settings = AppSettingsState.getInstance();
|
||||||
boolean modified = mySettingsComponent.getShowTreeComment() != settings.showTreeComment;
|
boolean modified = mySettingsComponent.getShowTreeComment() != settings.showTreeComment;
|
||||||
|
modified |= !mySettingsComponent.getTreeTags().equals(settings.treeTags);
|
||||||
modified |= mySettingsComponent.getShowLineEndComment() != settings.showLineEndComment;
|
modified |= mySettingsComponent.getShowLineEndComment() != settings.showLineEndComment;
|
||||||
|
modified |= !mySettingsComponent.getLineTags().equals(settings.lineTags);
|
||||||
|
|
||||||
modified |= !mySettingsComponent.getLineEndCount().equals(String.valueOf(settings.lineEndCount));
|
modified |= !mySettingsComponent.getLineEndCount().equals(String.valueOf(settings.lineEndCount));
|
||||||
modified |= !mySettingsComponent.getLineEndColor().equals(settings.lineEndTextAttr.getForegroundColor());
|
modified |= !mySettingsComponent.getLineEndColor().equals(settings.lineEndTextAttr.getForegroundColor());
|
||||||
@@ -58,7 +60,9 @@ public class AppSettingsConfigurable implements Configurable {
|
|||||||
public void apply() {
|
public void apply() {
|
||||||
AppSettingsState settings = AppSettingsState.getInstance();
|
AppSettingsState settings = AppSettingsState.getInstance();
|
||||||
settings.showTreeComment = mySettingsComponent.getShowTreeComment();
|
settings.showTreeComment = mySettingsComponent.getShowTreeComment();
|
||||||
|
settings.treeTags = mySettingsComponent.getTreeTags();
|
||||||
settings.showLineEndComment = mySettingsComponent.getShowLineEndComment();
|
settings.showLineEndComment = mySettingsComponent.getShowLineEndComment();
|
||||||
|
settings.lineTags = mySettingsComponent.getLineTags();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
settings.lineEndCount = Integer.parseInt(mySettingsComponent.getLineEndCount());
|
settings.lineEndCount = Integer.parseInt(mySettingsComponent.getLineEndCount());
|
||||||
@@ -86,7 +90,9 @@ public class AppSettingsConfigurable implements Configurable {
|
|||||||
public void reset() {
|
public void reset() {
|
||||||
AppSettingsState settings = AppSettingsState.getInstance();
|
AppSettingsState settings = AppSettingsState.getInstance();
|
||||||
mySettingsComponent.setShowTreeComment(settings.showTreeComment);
|
mySettingsComponent.setShowTreeComment(settings.showTreeComment);
|
||||||
|
mySettingsComponent.setTreeTags(settings.treeTags);
|
||||||
mySettingsComponent.setShowLineEndComment(settings.showLineEndComment);
|
mySettingsComponent.setShowLineEndComment(settings.showLineEndComment);
|
||||||
|
mySettingsComponent.setLineTags(settings.lineTags);
|
||||||
|
|
||||||
mySettingsComponent.setLineEndCount(String.valueOf(settings.lineEndCount));
|
mySettingsComponent.setLineEndCount(String.valueOf(settings.lineEndCount));
|
||||||
mySettingsComponent.setLineEndColor(settings.lineEndTextAttr.getForegroundColor());
|
mySettingsComponent.setLineEndColor(settings.lineEndTextAttr.getForegroundColor());
|
||||||
|
|||||||
@@ -21,7 +21,9 @@ import java.math.BigInteger;
|
|||||||
public class AppSettingsState extends AbstractSettingsState implements PersistentStateComponent<AppSettingsState> {
|
public class AppSettingsState extends AbstractSettingsState implements PersistentStateComponent<AppSettingsState> {
|
||||||
|
|
||||||
public boolean showTreeComment = true;
|
public boolean showTreeComment = true;
|
||||||
|
public String treeTags = "author";
|
||||||
public boolean showLineEndComment = true;
|
public boolean showLineEndComment = true;
|
||||||
|
public String lineTags = "author";
|
||||||
|
|
||||||
public final TextAttributes lineEndTextAttr = new TextAttributes(
|
public final TextAttributes lineEndTextAttr = new TextAttributes(
|
||||||
new JBColor(new Color(98, 151, 85), new Color(98, 151, 85)),
|
new JBColor(new Color(98, 151, 85), new Color(98, 151, 85)),
|
||||||
|
|||||||
Reference in New Issue
Block a user