Color save, async, set, end with multi key, COBOL key demo | 颜色保存,异步,多 key 结束,COBOL 关键字示例

This commit is contained in:
林万程
2022-04-13 02:04:27 +08:00
parent baa50ba361
commit 7033ae5704
11 changed files with 60 additions and 40 deletions

View File

@@ -71,7 +71,7 @@ https://plugins.jetbrains.com/plugin/18553-show-comment
<h2>中文更新说明:</h2>
<ul>
<li>1.12 增加 带行末注释复制 和 添加行末注释
<li>1.13 增加 带行末注释复制 和 添加行末注释
<li>1.12 ★ 外部注释用于 COBOL 等
<li>1.11 增加 json 跳转到字段
<li>1.10 增加 在父包和其他项目的包中获取 项目导航栏注释

View File

@@ -56,7 +56,7 @@ patchPluginXml {
<h2>中文更新说明:</h2>
<ul>
<li>1.12 增加 带行末注释复制 和 添加行末注释
<li>1.13 增加 带行末注释复制 和 添加行末注释
<li>1.12 ★ 外部注释用于 COBOL 等
<li>1.11 增加 json 跳转到字段
<li>1.10 增加 在父包和其他项目的包中获取 项目导航栏注释

View File

@@ -3,6 +3,7 @@ package io.github.linwancen.plugin.show;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.CommonDataKeys;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.command.WriteCommandAction;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.project.Project;
@@ -34,7 +35,7 @@ public class LineEndAdd extends AnAction {
}
ListPopup confirmation = JBPopupFactory.getInstance().createConfirmation(
"Add Line Comment?", "Add and replace files!", "Don't add.",
() -> addDocAll(project, files), 2);
() -> ApplicationManager.getApplication().runReadAction(() -> addDocAll(project, files)), 2);
confirmation.showInFocusCenter();
}
@@ -45,7 +46,7 @@ public class LineEndAdd extends AnAction {
@Override
public boolean visitFile(@NotNull VirtualFile file) {
if (!file.isDirectory()) {
addDoc(project, file, settings);
ApplicationManager.getApplication().runReadAction(() -> addDoc(project, file, settings));
}
return true;
}

View File

@@ -3,6 +3,7 @@ package io.github.linwancen.plugin.show;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.CommonDataKeys;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.editor.Caret;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.editor.Editor;
@@ -24,6 +25,10 @@ public class LineEndCopy extends AnAction {
@Override
public void actionPerformed(@NotNull AnActionEvent event) {
ApplicationManager.getApplication().runReadAction(() -> copyWithDoc(event));
}
private void copyWithDoc(@NotNull AnActionEvent event) {
Project project = event.getProject();
VirtualFile file = event.getData(CommonDataKeys.VIRTUAL_FILE);
if (file == null) {

View File

@@ -70,6 +70,11 @@ public class LineExt {
}
appendKeyDoc(sb, matcher, keyMap);
}
int before;
do {
before = sb.length();
appendKeyDoc(sb, matcher, keyMap);
} while (sb.length() != before);
if (!haveDoc) {
return null;
}

View File

@@ -4,12 +4,13 @@ import com.intellij.openapi.project.Project;
import com.intellij.psi.PsiClass;
import io.github.linwancen.plugin.show.settings.AppSettingsState;
import io.github.linwancen.plugin.show.settings.ProjectSettingsState;
import org.jetbrains.annotations.NotNull;
class PsiClassSkip {
private PsiClassSkip() {}
static boolean skip(PsiClass psiClass, Project project) {
static boolean skip(PsiClass psiClass, @NotNull Project project) {
if (psiClass == null) {
return true;
}

View File

@@ -1,8 +1,6 @@
package io.github.linwancen.plugin.show.settings;
import com.intellij.openapi.editor.colors.EditorColorsManager;
import com.intellij.openapi.options.Configurable;
import com.intellij.ui.JBColor;
import org.jetbrains.annotations.Nls;
import org.jetbrains.annotations.Nullable;
@@ -39,11 +37,7 @@ public class AppSettingsConfigurable implements Configurable {
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 {
modified |= !mySettingsComponent.getLineEndColor().equals(settings.lineEndColorBright);
}
modified |= !mySettingsComponent.getLineEndColor().equals(settings.lineEndTextAttr.getForegroundColor());
modified |= !mySettingsComponent.getLineEndJsonColor().equals(settings.lineEndJsonTextAttr.getForegroundColor());
modified |= mySettingsComponent.getFindElementRightToLeft() != settings.findElementRightToLeft;
modified |= !mySettingsComponent.getLineEndInclude().equals(settings.lineEndInclude);
@@ -62,13 +56,7 @@ public class AppSettingsConfigurable implements Configurable {
settings.fromNew = mySettingsComponent.getFromNew();
settings.fromRef = mySettingsComponent.getFromRef();
settings.inJson = mySettingsComponent.getInJson();
if (EditorColorsManager.getInstance().isDarkEditor()) {
settings.lineEndColorDark = mySettingsComponent.getLineEndColor();
} else {
settings.lineEndColorBright = mySettingsComponent.getLineEndColor();
}
JBColor jbColor = new JBColor(settings.lineEndColorBright, settings.lineEndColorDark);
settings.lineEndTextAttr.setForegroundColor(jbColor);
settings.lineEndTextAttr.setForegroundColor(mySettingsComponent.getLineEndColor());
settings.lineEndJsonTextAttr.setForegroundColor(mySettingsComponent.getLineEndJsonColor());
settings.findElementRightToLeft = mySettingsComponent.getFindElementRightToLeft();
settings.lineEndInclude = mySettingsComponent.getLineEndInclude();
@@ -92,11 +80,7 @@ public class AppSettingsConfigurable implements Configurable {
mySettingsComponent.setFromNew(settings.fromNew);
mySettingsComponent.setFromRef(settings.fromRef);
mySettingsComponent.setInJson(settings.inJson);
if (EditorColorsManager.getInstance().isDarkEditor()) {
mySettingsComponent.setLineEndColor(settings.lineEndColorDark);
} else {
mySettingsComponent.setLineEndColor(settings.lineEndColorBright);
}
mySettingsComponent.setLineEndColor(settings.lineEndTextAttr.getForegroundColor());
mySettingsComponent.setLineEndJsonColor(settings.lineEndJsonTextAttr.getForegroundColor());
mySettingsComponent.setFindElementRightToLeft(settings.findElementRightToLeft);
mySettingsComponent.setLineEndInclude(settings.lineEndInclude);

View File

@@ -12,9 +12,10 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.awt.*;
import java.math.BigInteger;
@State(
name = "io.github.linwancen.plugin.comment.settings.AppSettingsState",
name = "io.github.linwancen.plugin.show.settings.AppSettingsState",
storages = @Storage("ShowCommentGlobal.xml")
)
public class AppSettingsState implements PersistentStateComponent<AppSettingsState> {
@@ -22,11 +23,8 @@ public class AppSettingsState implements PersistentStateComponent<AppSettingsSta
public boolean showTreeComment = true;
public boolean showLineEndComment = true;
@SuppressWarnings("UseJBColor")
public Color lineEndColorBright = new Color(98, 151, 85);
@SuppressWarnings("UseJBColor")
public Color lineEndColorDark = new Color(98, 151, 85);
public final TextAttributes lineEndTextAttr = new TextAttributes(new JBColor(lineEndColorBright, lineEndColorDark),
public final TextAttributes lineEndTextAttr = new TextAttributes(
new JBColor(new Color(98, 151, 85), new Color(98, 151, 85)),
null, null, null, Font.ITALIC);
public final TextAttributes lineEndJsonTextAttr = new TextAttributes(new JBColor(Gray._140, Gray._140),
null, null, null, Font.ITALIC);
@@ -46,7 +44,11 @@ public class AppSettingsState implements PersistentStateComponent<AppSettingsSta
public String[] lineEndExcludeArray = {"java."};
public static AppSettingsState getInstance() {
return ApplicationManager.getApplication().getService(AppSettingsState.class);
AppSettingsState service = ApplicationManager.getApplication().getService(AppSettingsState.class);
if (service == null) {
return new AppSettingsState();
}
return service;
}
@Nullable
@@ -59,4 +61,22 @@ public class AppSettingsState implements PersistentStateComponent<AppSettingsSta
public void loadState(@NotNull AppSettingsState state) {
XmlSerializerUtil.copyBean(state, this);
}
public String getLineEndColor() {
return Integer.toHexString(lineEndTextAttr.getForegroundColor().getRGB()).toUpperCase();
}
public void setLineEndColor(String s) {
int rgb = new BigInteger(s, 16).intValue();
lineEndTextAttr.setForegroundColor(new JBColor(new Color(rgb), new Color(rgb)));
}
public String getLineEndJsonColor() {
return Integer.toHexString(lineEndJsonTextAttr.getForegroundColor().getRGB()).toUpperCase();
}
public void setLineEndJsonColor(String s) {
int rgb = new BigInteger(s, 16).intValue();
lineEndJsonTextAttr.setForegroundColor(new JBColor(new Color(rgb), new Color(rgb)));
}
}

View File

@@ -9,7 +9,7 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@State(
name = "io.github.linwancen.plugin.comment.settings.ProjectSettingsState",
name = "io.github.linwancen.plugin.show.settings.ProjectSettingsState",
storages = @Storage("ShowCommentProject.xml")
)
public class ProjectSettingsState implements PersistentStateComponent<ProjectSettingsState> {
@@ -21,8 +21,12 @@ public class ProjectSettingsState implements PersistentStateComponent<ProjectSet
public String[] lineEndIncludeArray = {};
public String[] lineEndExcludeArray = {};
public static ProjectSettingsState getInstance(Project project) {
return project.getService(ProjectSettingsState.class);
public static ProjectSettingsState getInstance(@NotNull Project project) {
ProjectSettingsState service = project.getService(ProjectSettingsState.class);
if (service == null) {
return new ProjectSettingsState();
}
return service;
}
@Nullable

View File

@@ -13,12 +13,12 @@
IF if
有些程序 THEN 没有换行所以要加这个关键字
THEN
NOT(?= ) !
AND(?= ) &&
OR(?= ) ||
NOT(?= |$) !
AND(?= |$) &&
OR(?= |$) ||
兼容字符串字典
\=(?! ?') =
\=(?! ?'\d| '\w') =
> >
< <
1 COBOL 必要【关键字】
13 NOT(?= ) NOT(?= |$) !
14 AND(?= ) AND(?= |$) &&
15 OR(?= ) OR(?= |$) ||
16 兼容字符串字典
17 \=(?! ?') \=(?! ?'\d| '\w') =
18 > >
19 < <
20 PERFORM call
21 WS-
22 (?<!\w)\( (
23 \) )
24

View File

@@ -1,7 +1,7 @@
123456 INITIALIZE HELLO-WORLD
IF (KEY NOT = '1' AND '2')
AND KEY NOT = '1' THEN
IF (KEY NOT = '1' AND '2') AND
KEY NOT = '1' THEN
MOVE WS-HELLO-WORLD TO HELLO-WORLD
END IF
TABLE(STRUCT)