1.12 ★ External Comment for COBOL etc | 外部注释用于 COBOL 等

This commit is contained in:
林万程
2022-04-06 23:08:03 +08:00
parent ac4ed47c9f
commit 879d61e34a
45 changed files with 1625 additions and 88 deletions

View File

@@ -19,24 +19,18 @@ public class LineDocRightToLeftUtils {
// End is always white, can not -1 because @see class.name need it
PsiElement element = viewProvider.findElementAt(endOffset);
if (element == null) {
// one line end
return null;
}
AppSettingsState instance = AppSettingsState.getInstance();
PsiElement identifier;
PsiDocComment psiDocComment;
AppSettingsState setting = AppSettingsState.getInstance();
while (true) {
identifier = PsiTreeUtil.prevVisibleLeaf(element);
PsiElement identifier = PsiTreeUtil.prevVisibleLeaf(element);
if (identifier != null && identifier.getTextRange().getStartOffset() < startOffset) {
identifier = null;
}
if (identifier == null || identifier instanceof PsiIdentifier) {
if (instance.inJson && element.getLanguage().is(JsonLanguage.INSTANCE)) {
return JsonDocUtils.jsonDoc(element, startOffset, endOffset);
}
psiDocComment = LineDocUtils.elementDoc(element, identifier, startOffset, endOffset);
if (psiDocComment != null) {
return psiDocComment;
}
PsiDocComment docComment = psiDoc(setting, identifier, element, startOffset, endOffset);
if (docComment != null) {
return docComment;
}
if (identifier == null) {
return null;
@@ -44,4 +38,16 @@ public class LineDocRightToLeftUtils {
element = identifier;
}
}
public static PsiDocComment psiDoc(AppSettingsState setting,
PsiElement identifier, PsiElement element,
int startOffset, int endOffset) {
if (identifier != null && !(identifier instanceof PsiIdentifier)) {
return null;
}
if (setting.inJson && element.getLanguage().is(JsonLanguage.INSTANCE)) {
return JsonDocUtils.jsonDoc(element, startOffset, endOffset);
}
return LineDocUtils.elementDoc(element, identifier, startOffset, endOffset);
}
}