sort tag doc | 标签注释排序

This commit is contained in:
林万程
2022-06-28 02:21:06 +08:00
parent 13d96d4b49
commit ab8b4c449f
4 changed files with 15 additions and 14 deletions

View File

@@ -78,10 +78,10 @@ public class PsiDocToStrDoc {
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)) {
String[] names = isTree ? appSettings.treeTags : appSettings.lineTags;
for (String name : names) {
PsiDocTag[] tags = psiDocComment.findTagsByName(name);
for (PsiDocTag tag : tags) {
// @see @param should use getDataElements()
PsiDocTagValue value = tag.getValueElement();
if (value != null) {

View File

@@ -44,8 +44,8 @@ public class AppSettingsComponent extends AbstractSettingsComponent {
JPanel comment = FormBuilder.createFormBuilder()
.addComponent(showTreeComment, 1)
.addComponent(showLineEndComment, 1)
.addLabeledComponent(new JBLabel("tree tags"), treeTags, 1, true)
.addLabeledComponent(new JBLabel("line tags"), lineTags, 1, true)
.addLabeledComponent(new JBLabel("tree tags split by |:"), treeTags, 1, true)
.addLabeledComponent(new JBLabel("line tags split by |:"), lineTags, 1, true)
.getPanel();
comment.setBorder(IdeBorderFactory.createTitledBorder("Show"));
return comment;

View File

@@ -1,5 +1,6 @@
package io.github.linwancen.plugin.show.settings;
import com.google.common.base.Splitter;
import com.intellij.openapi.options.Configurable;
import org.jetbrains.annotations.Nls;
import org.jetbrains.annotations.Nullable;
@@ -32,9 +33,9 @@ public class AppSettingsConfigurable implements Configurable {
public boolean isModified() {
AppSettingsState settings = AppSettingsState.getInstance();
boolean modified = mySettingsComponent.getShowTreeComment() != settings.showTreeComment;
modified |= !mySettingsComponent.getTreeTags().equals(settings.treeTags);
modified |= !mySettingsComponent.getTreeTags().equals(String.join("|", settings.treeTags));
modified |= mySettingsComponent.getShowLineEndComment() != settings.showLineEndComment;
modified |= !mySettingsComponent.getLineTags().equals(settings.lineTags);
modified |= !mySettingsComponent.getLineTags().equals(String.join("|", settings.lineTags));
modified |= !mySettingsComponent.getLineEndCount().equals(String.valueOf(settings.lineEndCount));
modified |= !mySettingsComponent.getLineEndColor().equals(settings.lineEndTextAttr.getForegroundColor());
@@ -60,9 +61,9 @@ public class AppSettingsConfigurable implements Configurable {
public void apply() {
AppSettingsState settings = AppSettingsState.getInstance();
settings.showTreeComment = mySettingsComponent.getShowTreeComment();
settings.treeTags = mySettingsComponent.getTreeTags();
settings.treeTags = Splitter.on('|').splitToList(mySettingsComponent.getTreeTags()).toArray(new String[0]);
settings.showLineEndComment = mySettingsComponent.getShowLineEndComment();
settings.lineTags = mySettingsComponent.getLineTags();
settings.lineTags = Splitter.on('|').splitToList(mySettingsComponent.getLineTags()).toArray(new String[0]);
try {
settings.lineEndCount = Integer.parseInt(mySettingsComponent.getLineEndCount());
@@ -90,9 +91,9 @@ public class AppSettingsConfigurable implements Configurable {
public void reset() {
AppSettingsState settings = AppSettingsState.getInstance();
mySettingsComponent.setShowTreeComment(settings.showTreeComment);
mySettingsComponent.setTreeTags(settings.treeTags);
mySettingsComponent.setTreeTags(String.join("|", settings.treeTags));
mySettingsComponent.setShowLineEndComment(settings.showLineEndComment);
mySettingsComponent.setLineTags(settings.lineTags);
mySettingsComponent.setLineTags(String.join("|", settings.lineTags));
mySettingsComponent.setLineEndCount(String.valueOf(settings.lineEndCount));
mySettingsComponent.setLineEndColor(settings.lineEndTextAttr.getForegroundColor());

View File

@@ -21,9 +21,9 @@ import java.math.BigInteger;
public class AppSettingsState extends AbstractSettingsState implements PersistentStateComponent<AppSettingsState> {
public boolean showTreeComment = true;
public String treeTags = "author";
public String[] treeTags = {"author"};
public boolean showLineEndComment = true;
public String lineTags = "author";
public String[] lineTags = {"author"};
public final TextAttributes lineEndTextAttr = new TextAttributes(
new JBColor(new Color(98, 151, 85), new Color(98, 151, 85)),