1.8 Add line-end-comment for json | 增加从同后缀的类中读取 json 行末注释

This commit is contained in:
林万程
2022-03-06 14:17:13 +08:00
parent 7843ab2421
commit 6882ac7f7b
22 changed files with 371 additions and 137 deletions

View File

@@ -1,7 +1,7 @@
# Show Comment Plugin
IDEA 智能注释插件
English Note:
English Notes:
- Show javadoc comments in the Project view Tree structure.
- Show javadoc comments for calling methods at the end of the line.
- One of the above features
@@ -11,17 +11,33 @@ English Note:
- End-of-line comment class prefix filter
can be modified in settings -> Tools -> Show Comment Project.
Chinese Note:
Chinese Notes:
- 在结构树显示 当前节点 的文档注释。
- 在行末尾显示 调用方法 的文档注释。
- 可以在设置中 关闭 上面其中一个功能。
- 可以在设置中 修改 行末注释的颜色。
- 可以在设置中 修改 行末注释类前缀过滤。
Change Log:
- 1.1 Add end-of-line text color settings | 添加行末文本颜色配置
- 1.2 Add end-of-line comment class prefix filter settings | 添加行末注释类前缀过滤配置
- 1.3 support class in tree, constructor and field type in line end | 支持 class 树节点、构造方法和字段的行末注释
- 1.4 Find element right to left for end-of-line comment | 从右往左查找行末注释对象
- 1.5 Support find next loop when not comment | 支持没有注释时循环查找下一个对象
- 1.6 Add end-of-line comment independent switch for call,new,ref | 增加行末调用new引用注释独立开关
English Change Notes:
<ul>
<li>1.8 Add line-end-comment for json
<li>1.7 Add line-end-comment setting for prefix and count
<li>1.6 Add line-end-comment independent switch for call, new, ref
<li>1.5 Add line-end-comment find next loop when none
<li>1.4 Add line-end-comment find element right to left
<li>1.3 Add project-view-tree-comment
<li>1.2 Add line-end-comment settings fro class prefix filter
<li>1.1 Add line-end-comment settings for text color
</ul>
Chinese Change Notes:
<ul>
<li>1.8 增加 从同后缀的类中读取 json 行末注释
<li>1.7 增加 行末注释前缀和对象数设置
<li>1.6 增加 行末调用new引用注释独立开关
<li>1.5 增加 没有注释时循环查找下一个对象
<li>1.4 增加 从右往左查找行末注释对象
<li>1.3 增加 项目导航栏注释
<li>1.2 增加 行末注释类前缀配置
<li>1.1 增加 行末文本颜色配置
</ul>

View File

@@ -4,7 +4,7 @@ plugins {
}
group 'io.github.linwancen'
version '1.6.0.' + (new Date().format('yyyy.MM.dd_HH.mm'))
version '1.8.0.' + (new Date().format('yyyy.MM.dd_HH.mm'))
apply plugin: 'java'
@@ -37,14 +37,29 @@ patchPluginXml {
sinceBuild = '201.1'
untilBuild = ''
changeNotes = """
<ul>
<li>1.1 Add end-of-line text color settings | 添加行末文本颜色配置
<li>1.2 Add end-of-line comment class prefix filter settings | 添加行末注释类前缀配置
<li>1.3 Support class in tree, constructor and field type in line end | 支持 class 树节点、构造方法和字段的行末注释
<li>1.4 Find element right to left for end-of-line comment | 从右往左查找行末注释对象
<li>1.5 Support find next loop when not comment | 支持没有注释时循环查找下一个对象
<li>1.6 Add end-of-line comment independent switch for call,new,ref | 增加行末调用new引用注释独立开关
</ul>
English Change Notes:
<ul>
<li>1.8 Add line-end-comment for json
<li>1.7 Add line-end-comment setting for prefix and count
<li>1.6 Add line-end-comment independent switch for call, new, ref
<li>1.5 Add line-end-comment find next loop when none
<li>1.4 Add line-end-comment find element right to left
<li>1.3 Add project-view-tree-comment
<li>1.2 Add line-end-comment settings fro class prefix filter
<li>1.1 Add line-end-comment settings for text color
</ul>
Chinese Change Notes:
<ul>
<li>1.8 增加 从同后缀的类中读取 json 行末注释
<li>1.7 增加 行末注释前缀和对象数设置
<li>1.6 增加 行末调用new引用注释独立开关
<li>1.5 增加 没有注释时循环查找下一个对象
<li>1.4 增加 从右往左查找行末注释对象
<li>1.3 增加 项目导航栏注释
<li>1.2 增加 行末注释类前缀配置
<li>1.1 增加 行末文本颜色配置
</ul>
"""
}

View File

@@ -1,6 +1,5 @@
package io.github.linwancen.plugin.show;
import com.intellij.lang.java.JavaLanguage;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.editor.EditorLinePainter;
import com.intellij.openapi.editor.LineExtensionInfo;
@@ -33,17 +32,17 @@ public class LineEnd extends EditorLinePainter {
return null;
}
FileViewProvider viewProvider = PsiManager.getInstance(project).findViewProvider(file);
PsiDocComment docComment = docOwnerFrom(viewProvider, lineNumber);
PsiDocComment docComment = doc(project, viewProvider, lineNumber);
String comment = DocTextUtils.text(docComment);
if (comment == null) {
return null;
}
LineExtensionInfo info = new LineExtensionInfo(" //" + comment, settings.lineEndTextAttr);
LineExtensionInfo info = new LineExtensionInfo(settings.lineEndPrefix + comment, settings.lineEndTextAttr);
return Collections.singletonList(info);
}
private static @Nullable PsiDocComment docOwnerFrom(FileViewProvider viewProvider, int lineNumber) {
if (viewProvider == null || !viewProvider.hasLanguage(JavaLanguage.INSTANCE)) {
private static @Nullable PsiDocComment doc(Project project, FileViewProvider viewProvider, int lineNumber) {
if (viewProvider == null) {
return null;
}
Document document = viewProvider.getDocument();

View File

@@ -4,6 +4,7 @@ import com.intellij.psi.PsiElement;
import com.intellij.psi.javadoc.PsiDocComment;
import com.intellij.psi.javadoc.PsiDocToken;
import com.intellij.psi.javadoc.PsiInlineDocTag;
import io.github.linwancen.plugin.show.settings.AppSettingsState;
import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
@@ -18,6 +19,7 @@ public class DocTextUtils {
if (psiDocComment == null) {
return null;
}
AppSettingsState appSettings = AppSettingsState.getInstance();
List<String> comments = new ArrayList<>();
PsiElement[] elements = psiDocComment.getDescriptionElements();
for (PsiElement element : elements) {
@@ -31,22 +33,17 @@ public class DocTextUtils {
comments.add(children[2].getText());
}
}
if (comments.size() > 1) {
if (appSettings.lineEndCount > 0 && comments.size() >= appSettings.lineEndCount) {
break;
}
}
if (comments.isEmpty()) {
return null;
}
StringBuilder sb = new StringBuilder(comments.get(0).trim());
if (sb.length() == 0) {
return null;
StringBuilder sb = new StringBuilder(" ");
for (String s : comments) {
sb.append(s.trim().replace("<br>", "")).append(" ");
}
if (comments.size() > 1) {
sb.append(" ").append(comments.get(1).trim().replace("<br>", ""));
}
sb.insert(0, " ");
sb.append(" ");
return sb.toString();
}
}

View File

@@ -35,14 +35,14 @@ public class DocUtils {
@Nullable
public static PsiDocComment fileDoc(PsiFile psiFile) {
if (!(psiFile instanceof PsiJavaFile)) {
if (!(psiFile instanceof PsiClassOwner)) {
return null;
}
PsiJavaFile psiJavaFile = (PsiJavaFile) psiFile;
PsiClassOwner psiClassOwner = (PsiClassOwner) psiFile;
if (PsiPackage.PACKAGE_INFO_FILE.equals(psiFile.getName())) {
return PackageDocUtils.fromPackageInfoFile(psiFile);
}
PsiClass[] classes = psiJavaFile.getClasses();
PsiClass[] classes = psiClassOwner.getClasses();
if (classes.length == 0) {
return null;
}

View File

@@ -0,0 +1,86 @@
package io.github.linwancen.plugin.show.doc;
import com.intellij.json.psi.JsonProperty;
import com.intellij.openapi.project.Project;
import com.intellij.psi.JavaPsiFacade;
import com.intellij.psi.PsiClass;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiField;
import com.intellij.psi.javadoc.PsiDocComment;
import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.psi.search.PsiShortNamesCache;
import com.intellij.psi.util.PsiTreeUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class JsonDocUtils {
private static final Pattern JSON_PATTERN = Pattern.compile("[\\w.]*+$");
private JsonDocUtils() {}
@Nullable
public static PsiDocComment jsonDoc(PsiElement element, int startOffset, int endOffset) {
JsonProperty jsonProp = PsiTreeUtil.getParentOfType(element, JsonProperty.class, true, startOffset);
if (jsonProp == null || jsonProp.getNameElement().getTextRange().getEndOffset() > endOffset) {
return null;
}
String fileName = element.getContainingFile().getVirtualFile().getNameWithoutExtension();
Matcher matcher = JSON_PATTERN.matcher(fileName);
if (!matcher.find()) {
return null;
}
String className = matcher.group();
PsiClass[] psiClasses = classByName(className, element.getProject());
PsiField psiField = psiField(psiClasses, element.getProject(), jsonProp);
if (psiField != null) {
return DocUtils.srcOrByteCodeDoc(psiField);
}
return null;
}
@NotNull
private static PsiClass[] classByName(String className, @NotNull Project project) {
int i = className.indexOf('.');
if (i > 0) {
return classByFullName(className, project);
}
PsiShortNamesCache namesCache = PsiShortNamesCache.getInstance(project);
return namesCache.getClassesByName(className, GlobalSearchScope.allScope(project));
}
@NotNull
private static PsiClass[] classByFullName(String className, @NotNull Project project) {
JavaPsiFacade javaPsiFacade = JavaPsiFacade.getInstance(project);
return javaPsiFacade.findClasses(className, GlobalSearchScope.allScope(project));
}
@Nullable
private static PsiField psiField(PsiClass[] rootClasses, Project project, JsonProperty jsonProp) {
JsonProperty parentJsonProp = PsiTreeUtil.getParentOfType(jsonProp, JsonProperty.class);
if (parentJsonProp == null) {
for (PsiClass c : rootClasses) {
PsiField field = c.findFieldByName(jsonProp.getName(), true);
if (field != null) {
return field;
}
}
return null;
}
PsiField psiField = psiField(rootClasses, project, parentJsonProp);
if (psiField == null) {
return null;
}
String classFullName = psiField.getType().getCanonicalText();
@NotNull PsiClass[] psiClasses = classByFullName(classFullName, project);
for (PsiClass c : psiClasses) {
PsiField field = c.findFieldByName(jsonProp.getName(), true);
if (field != null) {
return field;
}
}
return null;
}
}

View File

@@ -1,6 +1,6 @@
package io.github.linwancen.plugin.show.line;
import com.intellij.lang.java.JavaLanguage;
import com.intellij.json.JsonLanguage;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.util.TextRange;
import com.intellij.psi.FileViewProvider;
@@ -8,6 +8,8 @@ import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiIdentifier;
import com.intellij.psi.javadoc.PsiDocComment;
import com.intellij.psi.util.PsiTreeUtil;
import io.github.linwancen.plugin.show.doc.JsonDocUtils;
import io.github.linwancen.plugin.show.settings.AppSettingsState;
import org.jetbrains.annotations.Nullable;
public class LineDocLeftToRightUtils {
@@ -44,16 +46,23 @@ public class LineDocLeftToRightUtils {
offset++;
}
offset += startOffset;
PsiElement element = viewProvider.findElementAt(offset);
if (element == null) {
return null;
}
AppSettingsState instance = AppSettingsState.getInstance();
if (instance.inJson && element.getLanguage().is(JsonLanguage.INSTANCE)) {
return JsonDocUtils.jsonDoc(element, startOffset, endOffset);
}
if (startWithSymbol) {
startOffset = 0;
}
PsiElement element = viewProvider.findElementAt(offset, JavaLanguage.INSTANCE);
return nextDoc(element, startOffset, endOffset);
}
@Nullable
private static PsiDocComment nextDoc(PsiElement element, int startOffset, int endOffset) {
while (element != null && element.getTextRange().getEndOffset() < endOffset) {
while (element.getTextRange().getEndOffset() < endOffset) {
if (element instanceof PsiIdentifier) {
PsiDocComment psiDocComment = LineDocUtils.elementDoc(element, element, startOffset, endOffset);
if (psiDocComment != null) {
@@ -61,6 +70,9 @@ public class LineDocLeftToRightUtils {
}
}
element = PsiTreeUtil.nextVisibleLeaf(element);
if (element == null) {
return null;
}
}
return null;
}

View File

@@ -1,11 +1,13 @@
package io.github.linwancen.plugin.show.line;
import com.intellij.lang.java.JavaLanguage;
import com.intellij.json.JsonLanguage;
import com.intellij.psi.FileViewProvider;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiIdentifier;
import com.intellij.psi.javadoc.PsiDocComment;
import com.intellij.psi.util.PsiTreeUtil;
import io.github.linwancen.plugin.show.doc.JsonDocUtils;
import io.github.linwancen.plugin.show.settings.AppSettingsState;
import org.jetbrains.annotations.Nullable;
public class LineDocRightToLeftUtils {
@@ -15,10 +17,11 @@ public class LineDocRightToLeftUtils {
@Nullable
public static PsiDocComment rightDoc(FileViewProvider viewProvider, int startOffset, int endOffset) {
// End is always white, can not -1 because @see class.name need it
PsiElement element = viewProvider.findElementAt(endOffset, JavaLanguage.INSTANCE);
PsiElement element = viewProvider.findElementAt(endOffset);
if (element == null) {
return null;
}
AppSettingsState instance = AppSettingsState.getInstance();
PsiElement identifier;
PsiDocComment psiDocComment;
while (true) {
@@ -27,6 +30,9 @@ public class LineDocRightToLeftUtils {
identifier = null;
}
if (identifier == null || identifier instanceof PsiIdentifier) {
if (instance.inJson && element.getLanguage().is(JsonLanguage.INSTANCE)) {
return JsonDocUtils.jsonDoc(element, startOffset, endOffset);
}
psiDocComment = LineDocUtils.elementDoc(element, identifier, startOffset, endOffset);
if (psiDocComment != null) {
return psiDocComment;

View File

@@ -16,32 +16,33 @@ class LineDocUtils {
int startOffset, int endOffset) {
AppSettingsState instance = AppSettingsState.getInstance();
if (element != null) {
PsiDocComment executableDoc = elementDoc(element, startOffset, endOffset, instance);
if (executableDoc != null) {
return executableDoc;
PsiDocComment elementDoc = elementDoc(element, startOffset, endOffset, instance);
if (elementDoc != null) {
return elementDoc;
}
}
if (instance.showLineEndCommentForRef) {
if (instance.fromRef) {
return refDoc(psiIdentifier, endOffset);
}
return null;
}
@Nullable
private static PsiDocComment elementDoc(PsiElement element, int startOffset, int endOffset, AppSettingsState instance) {
if (instance.showLineEndCommentForCall) {
private static PsiDocComment elementDoc(PsiElement element, int startOffset, int endOffset,
AppSettingsState instance) {
if (instance.fromCall) {
PsiDocComment executableDoc = parentMethodDoc(element, startOffset, endOffset);
if (executableDoc != null) {
return executableDoc;
}
}
if (instance.showLineEndCommentForNew) {
if (instance.fromNew) {
PsiDocComment newDoc = parentNewDoc(element, startOffset);
if (newDoc != null) {
return newDoc;
}
}
if (instance.showLineEndCommentForRef) {
if (instance.fromRef) {
return docRefDoc(element);
}
return null;

View File

@@ -3,6 +3,8 @@ package io.github.linwancen.plugin.show.settings;
import com.intellij.ui.ColorPanel;
import com.intellij.ui.IdeBorderFactory;
import com.intellij.ui.components.JBCheckBox;
import com.intellij.ui.components.JBLabel;
import com.intellij.ui.components.JBTextField;
import com.intellij.util.ui.FormBuilder;
import org.jetbrains.annotations.NotNull;
@@ -14,16 +16,18 @@ public class AppSettingsComponent extends AbstractSettingsComponent {
private final JPanel myMainPanel;
private final JBCheckBox showTreeComment = new JBCheckBox("Show tree comment ");
private final JBCheckBox showLineEndComment = new JBCheckBox("Show line end comment ");
private final JBCheckBox showLineEndCommentForCall = new JBCheckBox("Show line end comment for call ");
private final JBCheckBox showLineEndCommentForNew = new JBCheckBox("Show line end comment for new ");
private final JBCheckBox showLineEndCommentForRef = new JBCheckBox("Show line end comment for ref ");
private final JBCheckBox fromCall = new JBCheckBox("call ");
private final JBCheckBox fromNew = new JBCheckBox("new ");
private final JBCheckBox fromRef = new JBCheckBox("ref ");
private final JBCheckBox inJson = new JBCheckBox("in json ");
private final ColorPanel lineEndColor = new ColorPanel();
private final JBCheckBox findElementRightToLeft = new JBCheckBox("Find element right to left");
protected final JBTextField lineEndPrefix = new JBTextField();
protected final JBTextField lineEndCount = new JBTextField();
public AppSettingsComponent() {
myMainPanel = FormBuilder.createFormBuilder()
.addComponent(showPanel(), 1)
.addComponent(colorPanel(), 1)
.addComponent(lineEndFilterPanel(), 1)
.addComponentFillVertically(new JPanel(), 0)
.getPanel();
@@ -34,28 +38,23 @@ public class AppSettingsComponent extends AbstractSettingsComponent {
JPanel comment = FormBuilder.createFormBuilder()
.addComponent(showTreeComment, 1)
.addComponent(showLineEndComment, 1)
.addSeparator()
.addComponent(showLineEndCommentForCall, 1)
.addComponent(showLineEndCommentForNew, 1)
.addComponent(showLineEndCommentForRef, 1)
.getPanel();
comment.setBorder(IdeBorderFactory.createTitledBorder("Show"));
return comment;
}
@NotNull
private JPanel colorPanel() {
JPanel color = FormBuilder.createFormBuilder()
.addLabeledComponent(new JLabel("line end text color:"), lineEndColor)
.getPanel();
color.setBorder(IdeBorderFactory.createTitledBorder("Color"));
return color;
}
@NotNull
protected JPanel lineEndFilterPanel() {
JPanel text = JPanelFactory.of(
new JBLabel("object count: "), lineEndCount,
new JBLabel("text color: "), lineEndColor,
new JBLabel("prefix: "), lineEndPrefix);
FormBuilder formBuilder = FormBuilder.createFormBuilder()
.addComponent(findElementRightToLeft)
.addComponent(JPanelFactory.of(findElementRightToLeft))
.addSeparator()
.addComponent(JPanelFactory.of(fromCall, fromNew, fromRef, inJson), 1)
.addSeparator()
.addComponent(text)
.addSeparator();
return commonLineEndFilter(formBuilder);
}
@@ -85,28 +84,36 @@ public class AppSettingsComponent extends AbstractSettingsComponent {
showLineEndComment.setSelected(newStatus);
}
public boolean getShowLineEndCommentForCall() {
return showLineEndCommentForCall.isSelected();
public boolean getFromCall() {
return fromCall.isSelected();
}
public void setShowLineEndCommentForCall(boolean newStatus) {
showLineEndCommentForCall.setSelected(newStatus);
public void setFromCall(boolean newStatus) {
fromCall.setSelected(newStatus);
}
public boolean getShowLineEndCommentForNew() {
return showLineEndCommentForNew.isSelected();
public boolean getFromNew() {
return fromNew.isSelected();
}
public void setShowLineEndCommentForNew(boolean newStatus) {
showLineEndCommentForNew.setSelected(newStatus);
public void setFromNew(boolean newStatus) {
fromNew.setSelected(newStatus);
}
public boolean getShowLineEndCommentForRef() {
return showLineEndCommentForRef.isSelected();
public boolean getFromRef() {
return fromRef.isSelected();
}
public void setShowLineEndCommentForRef(boolean newStatus) {
showLineEndCommentForRef.setSelected(newStatus);
public void setFromRef(boolean newStatus) {
fromRef.setSelected(newStatus);
}
public boolean getInJson() {
return inJson.isSelected();
}
public void setInJson(boolean newStatus) {
inJson.setSelected(newStatus);
}
public Color getLineEndColor() {
@@ -124,4 +131,22 @@ public class AppSettingsComponent extends AbstractSettingsComponent {
public void setFindElementRightToLeft(boolean newStatus) {
findElementRightToLeft.setSelected(newStatus);
}
@NotNull
public String getLineEndPrefix() {
return lineEndPrefix.getText();
}
public void setLineEndPrefix(@NotNull String newText) {
lineEndPrefix.setText(newText);
}
@NotNull
public String getLineEndCount() {
return lineEndCount.getText();
}
public void setLineEndCount(@NotNull String newText) {
lineEndCount.setText(newText);
}
}

View File

@@ -35,9 +35,10 @@ public class AppSettingsConfigurable implements Configurable {
AppSettingsState settings = AppSettingsState.getInstance();
boolean modified = mySettingsComponent.getShowTreeComment() != settings.showTreeComment;
modified |= mySettingsComponent.getShowLineEndComment() != settings.showLineEndComment;
modified |= mySettingsComponent.getShowLineEndCommentForCall() != settings.showLineEndCommentForCall;
modified |= mySettingsComponent.getShowLineEndCommentForNew() != settings.showLineEndCommentForNew;
modified |= mySettingsComponent.getShowLineEndCommentForRef() != settings.showLineEndCommentForRef;
modified |= mySettingsComponent.getFromCall() != settings.fromCall;
modified |= mySettingsComponent.getFromNew() != settings.fromNew;
modified |= mySettingsComponent.getFromRef() != settings.fromRef;
modified |= mySettingsComponent.getInJson() != settings.inJson;
if (EditorColorsManager.getInstance().isDarkEditor()) {
modified |= !mySettingsComponent.getLineEndColor().equals(settings.lineEndColorDark);
} else {
@@ -46,6 +47,8 @@ public class AppSettingsConfigurable implements Configurable {
modified |= mySettingsComponent.getFindElementRightToLeft() != settings.findElementRightToLeft;
modified |= !mySettingsComponent.getLineEndInclude().equals(settings.lineEndInclude);
modified |= !mySettingsComponent.getLineEndExclude().equals(settings.lineEndExclude);
modified |= !mySettingsComponent.getLineEndPrefix().equals(settings.lineEndPrefix);
modified |= !mySettingsComponent.getLineEndCount().equals(String.valueOf(settings.lineEndCount));
return modified;
}
@@ -54,9 +57,10 @@ public class AppSettingsConfigurable implements Configurable {
AppSettingsState settings = AppSettingsState.getInstance();
settings.showTreeComment = mySettingsComponent.getShowTreeComment();
settings.showLineEndComment = mySettingsComponent.getShowLineEndComment();
settings.showLineEndCommentForCall = mySettingsComponent.getShowLineEndCommentForCall();
settings.showLineEndCommentForNew = mySettingsComponent.getShowLineEndCommentForNew();
settings.showLineEndCommentForRef = mySettingsComponent.getShowLineEndCommentForRef();
settings.fromCall = mySettingsComponent.getFromCall();
settings.fromNew = mySettingsComponent.getFromNew();
settings.fromRef = mySettingsComponent.getFromRef();
settings.inJson = mySettingsComponent.getInJson();
if (EditorColorsManager.getInstance().isDarkEditor()) {
settings.lineEndColorDark = mySettingsComponent.getLineEndColor();
} else {
@@ -69,6 +73,12 @@ public class AppSettingsConfigurable implements Configurable {
settings.lineEndExclude = mySettingsComponent.getLineEndExclude();
settings.lineEndIncludeArray = SplitUtils.split(settings.lineEndInclude);
settings.lineEndExcludeArray = SplitUtils.split(settings.lineEndExclude);
settings.lineEndPrefix = mySettingsComponent.getLineEndPrefix();
try {
settings.lineEndCount = Integer.parseInt(mySettingsComponent.getLineEndCount());
} catch (NumberFormatException e) {
mySettingsComponent.setLineEndCount(String.valueOf(settings.lineEndCount));
}
}
@Override
@@ -76,9 +86,10 @@ public class AppSettingsConfigurable implements Configurable {
AppSettingsState settings = AppSettingsState.getInstance();
mySettingsComponent.setShowTreeComment(settings.showTreeComment);
mySettingsComponent.setShowLineEndComment(settings.showLineEndComment);
mySettingsComponent.setShowLineEndCommentForCall(settings.showLineEndCommentForCall);
mySettingsComponent.setShowLineEndCommentForNew(settings.showLineEndCommentForNew);
mySettingsComponent.setShowLineEndCommentForRef(settings.showLineEndCommentForRef);
mySettingsComponent.setFromCall(settings.fromCall);
mySettingsComponent.setFromNew(settings.fromNew);
mySettingsComponent.setFromRef(settings.fromRef);
mySettingsComponent.setInJson(settings.inJson);
if (EditorColorsManager.getInstance().isDarkEditor()) {
mySettingsComponent.setLineEndColor(settings.lineEndColorDark);
} else {
@@ -87,6 +98,8 @@ public class AppSettingsConfigurable implements Configurable {
mySettingsComponent.setFindElementRightToLeft(settings.findElementRightToLeft);
mySettingsComponent.setLineEndInclude(settings.lineEndInclude);
mySettingsComponent.setLineEndExclude(settings.lineEndExclude);
mySettingsComponent.setLineEndPrefix(settings.lineEndPrefix);
mySettingsComponent.setLineEndCount(String.valueOf(settings.lineEndCount));
}
@Override

View File

@@ -21,10 +21,6 @@ public class AppSettingsState implements PersistentStateComponent<AppSettingsSta
public boolean showTreeComment = true;
public boolean showLineEndComment = true;
public boolean showLineEndCommentForCall = true;
public boolean showLineEndCommentForNew = true;
public boolean showLineEndCommentForRef = true;
@SuppressWarnings("all")
public Color lineEndColorBright = new Color(98, 151, 85);
@SuppressWarnings("all")
@@ -33,6 +29,13 @@ public class AppSettingsState implements PersistentStateComponent<AppSettingsSta
null, null, null, Font.ITALIC);
public boolean findElementRightToLeft = true;
public String lineEndPrefix = " //";
public int lineEndCount = 2;
public boolean fromCall = true;
public boolean fromNew = true;
public boolean fromRef = true;
public boolean inJson = true;
public String lineEndInclude = "";
public String lineEndExclude = "java.";
public String[] lineEndIncludeArray = {};

View File

@@ -0,0 +1,17 @@
package io.github.linwancen.plugin.show.settings;
import javax.swing.*;
import java.awt.*;
public class JPanelFactory {
private JPanelFactory() {}
public static JPanel of(Component... components) {
JPanel jPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
for (Component component : components) {
jPanel.add(component);
}
return jPanel;
}
}

View File

@@ -4,7 +4,7 @@
<vendor email="1498425439@qq.com" url="https://github.com/LinWanCen/show-comment">林万程</vendor>
<description><![CDATA[
English Note:
English Notes:
<ul>
<li>Show javadoc comments at the Project view Tree structure.
<li>Show javadoc comments at the end-of-line.
@@ -15,7 +15,7 @@
<li>Class name prefix filter of end-of-line comment can be modified in<br>
settings -> Tools -> Show Comment Project
</ul>
Chinese Note:
Chinese Notes:
<ul>
<li>在结构树显示 文档注释。
<li>在行末尾显示 文档注释。

View File

@@ -11,20 +11,14 @@ package io.github.linwancen.plugin.show.demo;
* @see InDoc
*/
public class InDoc {
/**
* field
*/
/** field */
public String field;
/**
* method()
*/
/** method() */
public void method1() {
}
/**
* method(InDoc)
*/
/** method(InDoc) */
public void method2(InDoc inDoc) {
}
}

View File

@@ -0,0 +1,11 @@
{
"integer": 0,
"str": "",
"date": "2022-03-04 21:34:01",
"bool": false,
"nestedClass": {
"nestedClass2": {
"a": "a"
}
}
}

View File

@@ -1,16 +1,12 @@
package io.github.linwancen.plugin.show.demo.method;
/**
* Child
*/
/** Child */
public class Child extends Parent implements Face {
public Child() {
}
/**
* Child(boolean bool)
*/
/** Child(boolean bool) */
public Child(boolean bool) {
this.bool = bool;
}
@@ -27,9 +23,7 @@ public class Child extends Parent implements Face {
}
/**
* fun
*/
/** fun */
public static Face fun(Face face) {
return null;
}
@@ -38,9 +32,7 @@ public class Child extends Parent implements Face {
return null;
}
/**
* bool
*/
/** bool */
public boolean bool;
public boolean isBool() {
@@ -48,9 +40,7 @@ public class Child extends Parent implements Face {
}
/**
* field
*/
/** field */
public Child field;
public Child getField() {

View File

@@ -1,12 +1,7 @@
package io.github.linwancen.plugin.show.demo.method;
/**
* Face
*/
//@FunctionalInterface
/** Face */
public interface Face {
/**
* faceMethod
*/
/** faceMethod */
Face faceMethod(Face face);
}

View File

@@ -1,12 +1,8 @@
package io.github.linwancen.plugin.show.demo.method;
/**
* Parent
*/
/** Parent */
public class Parent {
/**
* parentMethod
*/
/** parentMethod */
public Parent parentMethod() {
return null;
}

View File

@@ -0,0 +1,60 @@
package io.github.linwancen.plugin.show.demo.method;
import java.util.Date;
public class Pojo {
/** integer */
private int integer;
/** str */
private String str;
/** date */
private Date date;
/** bool */
private boolean bool;
/** nestedClass */
private NestedClass nestedClass;
/** NestedClass */
public static class NestedClass{
/** nestedClass2 */
private NestedClass2 nestedClass2;
/** NestedClass2 */
public static class NestedClass2{
/** a */
private String a;
}
}
public int getInteger() {
return integer;
}
public void setInteger(int integer) {
this.integer = integer;
}
public String getStr() {
return str;
}
public void setStr(String str) {
this.str = str;
}
public Date getDate() {
return date;
}
public void setDate(Date date) {
this.date = date;
}
public boolean isBool() {
return bool;
}
public void setBool(boolean bool) {
this.bool = bool;
}
}

View File

@@ -1,4 +1,2 @@
/**
* package doc
*/
/** package doc */
package io.github.linwancen.plugin.show.demo;

View File

@@ -10,7 +10,7 @@ import java.util.function.BiPredicate;
/**
* @see SkipUtils
*/
public class SkipUtilsTest {
class SkipUtilsTest {
public static final boolean o = true;
public static final boolean x = false;
@@ -30,7 +30,7 @@ public class SkipUtilsTest {
};
@Test
public void skipName() {
void skipName() {
// o include, x skip
boolean[][][] results = {{
// "java" -- name
@@ -77,7 +77,7 @@ public class SkipUtilsTest {
}
@Test
public void include() {
void include() {
boolean[][] results = {
// {"java", "io.a", "io.b"} -- name
{o, o, o}, // {},
@@ -89,7 +89,7 @@ public class SkipUtilsTest {
}
@Test
public void exclude() {
void exclude() {
boolean[][] results = {
// {"java", "io.a", "io.b"} ... names
{x, x, x}, // {},