1.16 skip when comments have been added | 已经添加行末注释时跳过
This commit is contained in:
@@ -3,7 +3,7 @@ IDEA 智能注释插件
|
||||
|
||||
https://plugins.jetbrains.com/plugin/18553-show-comment
|
||||
|
||||
|
||||
Thanks JetBrains Licenses for Open Source.
|
||||
|
||||
## Notes 说明
|
||||
|
||||
@@ -56,6 +56,7 @@ https://plugins.jetbrains.com/plugin/18553-show-comment
|
||||
|
||||
<h2>English Change Notes:</h2>
|
||||
<ul>
|
||||
<li>1.16 Add line-end-comment skip when comments have been added
|
||||
<li>1.15 Add line-end-comment support COBOL ext '', 'cbl', 'cob', 'cobol'
|
||||
<li>1.14 Add line-end-comment skip Annotation, skip only English (ASCII)
|
||||
<li>1.13 Add Copy With Line Comment & Add Line Comment
|
||||
@@ -75,6 +76,7 @@ https://plugins.jetbrains.com/plugin/18553-show-comment
|
||||
|
||||
<h2>中文更新说明:</h2>
|
||||
<ul>
|
||||
<li>1.16 增加 行末注释 已经添加行末注释时跳过
|
||||
<li>1.15 增加 行末注释 COBOL 拓展名支持 无拓展名、cbl、cob、cobol
|
||||
<li>1.14 增加 行末注释 忽略注解 与 忽略纯英文
|
||||
<li>1.13 增加 带行末注释复制 和 添加行末注释
|
||||
|
||||
@@ -4,7 +4,7 @@ plugins {
|
||||
}
|
||||
|
||||
group 'io.github.linwancen'
|
||||
version '1.15.0.' + (new Date().format('yyyy.MM.dd_HH.mm'))
|
||||
version '1.16.0.' + (new Date().format('yyyy.MM.dd_HH.mm'))
|
||||
|
||||
apply plugin: 'java'
|
||||
|
||||
@@ -39,6 +39,7 @@ patchPluginXml {
|
||||
changeNotes = """
|
||||
<h2>English Change Notes:</h2>
|
||||
<ul>
|
||||
<li>1.16 Add line-end-comment skip when comments have been added
|
||||
<li>1.15 Add line-end-comment support COBOL ext '', 'cbl', 'cob', 'cobol'
|
||||
<li>1.14 Add line-end-comment skip Annotation, skip only English (ASCII)
|
||||
<li>1.13 Add Copy With Line Comment & Add Line Comment
|
||||
@@ -58,6 +59,7 @@ patchPluginXml {
|
||||
|
||||
<h2>中文更新说明:</h2>
|
||||
<ul>
|
||||
<li>1.16 增加 行末注释 已经添加行末注释时跳过
|
||||
<li>1.15 增加 行末注释 COBOL 拓展名支持 无拓展名、cbl、cob、cobol
|
||||
<li>1.14 增加 行末注释 忽略注解 与 忽略纯英文
|
||||
<li>1.13 增加 带行末注释复制 和 添加行末注释
|
||||
|
||||
@@ -45,7 +45,7 @@ public class Tree implements ProjectViewNodeDecorator {
|
||||
if (coloredText.isEmpty()) {
|
||||
data.addText(data.getPresentableText(), SimpleTextAttributes.REGULAR_ATTRIBUTES);
|
||||
}
|
||||
data.addText(doc, SimpleTextAttributes.GRAY_ATTRIBUTES);
|
||||
data.addText(" " + doc, SimpleTextAttributes.GRAY_ATTRIBUTES);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -35,7 +35,6 @@ public class PsiDocToStrDoc {
|
||||
if (sb.length() == 0) {
|
||||
return null;
|
||||
}
|
||||
sb.insert(0, " ");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ import java.util.regex.Pattern;
|
||||
* call LineExt, ~LeftToRight, ~RightToLeft
|
||||
*/
|
||||
public class FileViewToDocStrUtils {
|
||||
|
||||
|
||||
public static final Pattern NOT_ASCII_PATTERN = Pattern.compile("[^\u0000-\u007f]");
|
||||
|
||||
private FileViewToDocStrUtils() {}
|
||||
@@ -32,21 +32,34 @@ public class FileViewToDocStrUtils {
|
||||
@Nullable VirtualFile file,
|
||||
@Nullable FileViewProvider viewProvider,
|
||||
int startOffset, int endOffset, @NotNull String text) {
|
||||
AppSettingsState setting = AppSettingsState.getInstance();
|
||||
if (file != null) {
|
||||
String extDoc = LineExt.extDoc(project, file.getPath(), file.getName(), file.getExtension(), text);
|
||||
int i = text.indexOf(setting.lineEndPrefix);
|
||||
String code = i <= 0 ? text : text.substring(0, i);
|
||||
String extDoc = LineExt.extDoc(project, file.getPath(), file.getName(), file.getExtension(), code);
|
||||
if (extDoc != null) {
|
||||
extDoc = extDoc.trim();
|
||||
if (text.endsWith(extDoc)) {
|
||||
return null;
|
||||
}
|
||||
return extDoc;
|
||||
}
|
||||
}
|
||||
if (viewProvider == null) {
|
||||
return null;
|
||||
}
|
||||
AppSettingsState setting = AppSettingsState.getInstance();
|
||||
PsiDocComment docComment = setting.findElementRightToLeft
|
||||
? FileViewToPsiDocRightToLeft.rightDoc(viewProvider, startOffset, endOffset)
|
||||
: FileViewToPsiDocLeftToRight.leftDoc(viewProvider, document, startOffset, endOffset);
|
||||
String strDoc = PsiDocToStrDoc.text(docComment);
|
||||
if (setting.skipAscii && strDoc != null && !NOT_ASCII_PATTERN.matcher(strDoc).find()) {
|
||||
if (strDoc == null) {
|
||||
return null;
|
||||
}
|
||||
strDoc = strDoc.trim();
|
||||
if (text.endsWith(strDoc)) {
|
||||
return null;
|
||||
}
|
||||
if (setting.skipAscii && !NOT_ASCII_PATTERN.matcher(strDoc).find()) {
|
||||
return null;
|
||||
}
|
||||
return strDoc;
|
||||
@@ -72,7 +85,7 @@ public class FileViewToDocStrUtils {
|
||||
String text = document.getText(new TextRange(startOffset, endOffset));
|
||||
sb.append(text);
|
||||
String doc = doc(document, project, file, viewProvider, startOffset, endOffset, text);
|
||||
if (doc != null) {
|
||||
if (doc != null && !text.endsWith(doc)) {
|
||||
sb.append(settings.lineEndPrefix).append(doc);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ public class AppSettingsState implements PersistentStateComponent<AppSettingsSta
|
||||
null, null, null, Font.ITALIC);
|
||||
|
||||
public boolean findElementRightToLeft = true;
|
||||
public String lineEndPrefix = " //";
|
||||
public String lineEndPrefix = " // ";
|
||||
public int lineEndCount = 2;
|
||||
public int lineEndLen = 0;
|
||||
public boolean fromCall = true;
|
||||
|
||||
Reference in New Issue
Block a user