1.4 Find element right to left for end-of-line comment | 从右往左查找行末注释对象

This commit is contained in:
林万程
2022-02-21 03:13:26 +08:00
parent 74d1f9adf5
commit ef6a2c034f
9 changed files with 232 additions and 148 deletions

View File

@@ -15,12 +15,13 @@ public class AppSettingsComponent extends AbstractSettingsComponent {
private final JBCheckBox showTreeComment = new JBCheckBox("Show tree comment ");
private final JBCheckBox showLineEndComment = new JBCheckBox("Show line end comment ");
private final ColorPanel lineEndColor = new ColorPanel();
private final JBCheckBox findElementRightToLeft = new JBCheckBox("Find element right to left");
public AppSettingsComponent() {
myMainPanel = FormBuilder.createFormBuilder()
.addComponent(showPanel(), 1)
.addComponent(colorPanel(), 1)
.addComponent(commonLineEndFilter(FormBuilder.createFormBuilder()), 1)
.addComponent(lineEndFilterPanel(), 1)
.addComponentFillVertically(new JPanel(), 0)
.getPanel();
}
@@ -44,6 +45,14 @@ public class AppSettingsComponent extends AbstractSettingsComponent {
return color;
}
@NotNull
protected JPanel lineEndFilterPanel() {
FormBuilder formBuilder = FormBuilder.createFormBuilder()
.addComponent(findElementRightToLeft)
.addSeparator();
return commonLineEndFilter(formBuilder);
}
public JPanel getPanel() {
return myMainPanel;
}
@@ -76,4 +85,12 @@ public class AppSettingsComponent extends AbstractSettingsComponent {
public void setLineEndColor(Color color) {
lineEndColor.setSelectedColor(color);
}
public boolean getFindElementRightToLeft() {
return findElementRightToLeft.isSelected();
}
public void setFindElementRightToLeft(boolean newStatus) {
findElementRightToLeft.setSelected(newStatus);
}
}

View File

@@ -40,6 +40,7 @@ public class AppSettingsConfigurable implements Configurable {
} else {
modified |= !mySettingsComponent.getLineEndColor().equals(settings.lineEndColorBright);
}
modified |= mySettingsComponent.getFindElementRightToLeft() != settings.findElementRightToLeft;
modified |= !mySettingsComponent.getLineEndInclude().equals(settings.lineEndInclude);
modified |= !mySettingsComponent.getLineEndExclude().equals(settings.lineEndExclude);
return modified;
@@ -57,6 +58,7 @@ public class AppSettingsConfigurable implements Configurable {
}
JBColor jbColor = new JBColor(settings.lineEndColorBright, settings.lineEndColorDark);
settings.lineEndTextAttr.setForegroundColor(jbColor);
settings.findElementRightToLeft = mySettingsComponent.getFindElementRightToLeft();
settings.lineEndInclude = mySettingsComponent.getLineEndInclude();
settings.lineEndExclude = mySettingsComponent.getLineEndExclude();
settings.lineEndIncludeArray = SplitUtils.split(settings.lineEndInclude);
@@ -73,6 +75,7 @@ public class AppSettingsConfigurable implements Configurable {
} else {
mySettingsComponent.setLineEndColor(settings.lineEndColorBright);
}
mySettingsComponent.setFindElementRightToLeft(settings.findElementRightToLeft);
mySettingsComponent.setLineEndInclude(settings.lineEndInclude);
mySettingsComponent.setLineEndExclude(settings.lineEndExclude);
}

View File

@@ -28,6 +28,7 @@ public class AppSettingsState implements PersistentStateComponent<AppSettingsSta
public final TextAttributes lineEndTextAttr = new TextAttributes(new JBColor(lineEndColorBright, lineEndColorDark),
null, null, null, Font.ITALIC);
public boolean findElementRightToLeft = true;
public String lineEndInclude = "";
public String lineEndExclude = "java.";
public String[] lineEndIncludeArray = {};