1.6 Add end-of-line comment independent switch for call,new,ref | 增加行末调用,new,引用注释独立开关
This commit is contained in:
@@ -23,4 +23,5 @@ Change Log:
|
||||
- 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.5 Support find next loop when not comment | 支持没有注释时循环查找下一个对象
|
||||
- 1.6 Add end-of-line comment independent switch for call,new,ref | 增加行末调用,new,引用注释独立开关
|
||||
@@ -4,7 +4,7 @@ plugins {
|
||||
}
|
||||
|
||||
group 'io.github.linwancen'
|
||||
version '1.5.0.' + (new Date().format('yyyy.MM.dd_HH.mm'))
|
||||
version '1.6.0.' + (new Date().format('yyyy.MM.dd_HH.mm'))
|
||||
|
||||
apply plugin: 'java'
|
||||
|
||||
@@ -43,6 +43,7 @@ patchPluginXml {
|
||||
<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>
|
||||
"""
|
||||
}
|
||||
|
||||
@@ -13,8 +13,8 @@ import com.intellij.psi.*;
|
||||
import com.intellij.psi.javadoc.PsiDocComment;
|
||||
import com.intellij.ui.ColoredTreeCellRenderer;
|
||||
import com.intellij.ui.SimpleTextAttributes;
|
||||
import io.github.linwancen.plugin.show.doc.DocUtils;
|
||||
import io.github.linwancen.plugin.show.doc.DocTextUtils;
|
||||
import io.github.linwancen.plugin.show.doc.DocUtils;
|
||||
import io.github.linwancen.plugin.show.settings.AppSettingsState;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.intellij.psi.*;
|
||||
import com.intellij.psi.impl.source.javadoc.PsiDocMethodOrFieldRef;
|
||||
import com.intellij.psi.javadoc.PsiDocComment;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import io.github.linwancen.plugin.show.settings.AppSettingsState;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
class LineDocUtils {
|
||||
@@ -13,21 +14,37 @@ class LineDocUtils {
|
||||
@Nullable
|
||||
static PsiDocComment elementDoc(PsiElement element, PsiElement psiIdentifier,
|
||||
int startOffset, int endOffset) {
|
||||
AppSettingsState instance = AppSettingsState.getInstance();
|
||||
if (element != null) {
|
||||
PsiDocComment executableDoc = elementDoc(element, startOffset, endOffset, instance);
|
||||
if (executableDoc != null) {
|
||||
return executableDoc;
|
||||
}
|
||||
}
|
||||
if (instance.showLineEndCommentForRef) {
|
||||
return refDoc(psiIdentifier, endOffset);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static PsiDocComment elementDoc(PsiElement element, int startOffset, int endOffset, AppSettingsState instance) {
|
||||
if (instance.showLineEndCommentForCall) {
|
||||
PsiDocComment executableDoc = parentMethodDoc(element, startOffset, endOffset);
|
||||
if (executableDoc != null) {
|
||||
return executableDoc;
|
||||
}
|
||||
}
|
||||
if (instance.showLineEndCommentForNew) {
|
||||
PsiDocComment newDoc = parentNewDoc(element, startOffset);
|
||||
if (newDoc != null) {
|
||||
return newDoc;
|
||||
}
|
||||
PsiDocComment docRefDoc = docRefDoc(element);
|
||||
if (docRefDoc != null) {
|
||||
return docRefDoc;
|
||||
}
|
||||
}
|
||||
return refDoc(psiIdentifier, endOffset);
|
||||
if (instance.showLineEndCommentForRef) {
|
||||
return docRefDoc(element);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
@@ -14,6 +14,9 @@ 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 ColorPanel lineEndColor = new ColorPanel();
|
||||
private final JBCheckBox findElementRightToLeft = new JBCheckBox("Find element right to left");
|
||||
|
||||
@@ -31,6 +34,10 @@ 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;
|
||||
@@ -78,6 +85,30 @@ public class AppSettingsComponent extends AbstractSettingsComponent {
|
||||
showLineEndComment.setSelected(newStatus);
|
||||
}
|
||||
|
||||
public boolean getShowLineEndCommentForCall() {
|
||||
return showLineEndCommentForCall.isSelected();
|
||||
}
|
||||
|
||||
public void setShowLineEndCommentForCall(boolean newStatus) {
|
||||
showLineEndCommentForCall.setSelected(newStatus);
|
||||
}
|
||||
|
||||
public boolean getShowLineEndCommentForNew() {
|
||||
return showLineEndCommentForNew.isSelected();
|
||||
}
|
||||
|
||||
public void setShowLineEndCommentForNew(boolean newStatus) {
|
||||
showLineEndCommentForNew.setSelected(newStatus);
|
||||
}
|
||||
|
||||
public boolean getShowLineEndCommentForRef() {
|
||||
return showLineEndCommentForRef.isSelected();
|
||||
}
|
||||
|
||||
public void setShowLineEndCommentForRef(boolean newStatus) {
|
||||
showLineEndCommentForRef.setSelected(newStatus);
|
||||
}
|
||||
|
||||
public Color getLineEndColor() {
|
||||
return lineEndColor.getSelectedColor();
|
||||
}
|
||||
|
||||
@@ -35,6 +35,9 @@ 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;
|
||||
if (EditorColorsManager.getInstance().isDarkEditor()) {
|
||||
modified |= !mySettingsComponent.getLineEndColor().equals(settings.lineEndColorDark);
|
||||
} else {
|
||||
@@ -51,6 +54,9 @@ 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();
|
||||
if (EditorColorsManager.getInstance().isDarkEditor()) {
|
||||
settings.lineEndColorDark = mySettingsComponent.getLineEndColor();
|
||||
} else {
|
||||
@@ -70,6 +76,9 @@ 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);
|
||||
if (EditorColorsManager.getInstance().isDarkEditor()) {
|
||||
mySettingsComponent.setLineEndColor(settings.lineEndColorDark);
|
||||
} else {
|
||||
|
||||
@@ -18,8 +18,12 @@ import java.awt.*;
|
||||
)
|
||||
public class AppSettingsState implements PersistentStateComponent<AppSettingsState> {
|
||||
|
||||
public boolean showLineEndComment = true;
|
||||
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);
|
||||
|
||||
Reference in New Issue
Block a user