2.10 not doc comment | 非文档注释
This commit is contained in:
@@ -9,6 +9,7 @@ import com.intellij.psi.util.PsiTreeUtil;
|
||||
import io.github.linwancen.plugin.show.bean.LineInfo;
|
||||
import io.github.linwancen.plugin.show.bean.SettingsInfo;
|
||||
import io.github.linwancen.plugin.show.java.doc.OwnerToPsiDocUtils;
|
||||
import io.github.linwancen.plugin.show.java.doc.PsiMethodToPsiDoc;
|
||||
import io.github.linwancen.plugin.show.java.line.OwnerToPsiDocSkip;
|
||||
import io.github.linwancen.plugin.show.lang.base.BaseTagLangDoc;
|
||||
import io.github.linwancen.plugin.show.lang.base.DocFilter;
|
||||
@@ -73,12 +74,24 @@ public class JavaLangDoc extends BaseTagLangDoc<PsiDocComment> {
|
||||
if (resolveDocPrint != null) {
|
||||
return resolveDocPrint;
|
||||
}
|
||||
// no doc comment support get set
|
||||
if (parseBaseComment(settingsInfo) && resolve instanceof PsiMethod) {
|
||||
@Nullable PsiField psiField = PsiMethodToPsiDoc.propMethodField((PsiMethod) resolve);
|
||||
if (psiField != null) {
|
||||
return super.resolveDocPrint(settingsInfo, psiField);
|
||||
}
|
||||
}
|
||||
if (settingsInfo.appSettings.fromParam && resolve instanceof PsiParameter) {
|
||||
return paramDoc((PsiParameter) resolve);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected <T extends SettingsInfo> boolean parseBaseComment(@NotNull T settingsInfo) {
|
||||
return settingsInfo.appSettings.showLineEndCommentJavaBase;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private String paramDoc(@NotNull PsiParameter psiParameter) {
|
||||
@Nullable PsiMethod method = PsiTreeUtil.getParentOfType(psiParameter, PsiMethod.class);
|
||||
|
||||
@@ -33,6 +33,11 @@ public class KotlinLangDoc extends BaseTagLangDoc<KDocSection> {
|
||||
return lineInfo.appSettings.showLineEndCommentKotlin;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected <T extends SettingsInfo> boolean parseBaseComment(@NotNull T settingsInfo) {
|
||||
return settingsInfo.appSettings.showLineEndCommentKotlinBase;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
protected <T extends SettingsInfo> KDocSection toDocElement(@NotNull T settingsInfo, @NotNull PsiElement resolve) {
|
||||
|
||||
@@ -8,7 +8,7 @@ import com.intellij.psi.javadoc.PsiDocComment;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
class PsiMethodToPsiDoc {
|
||||
public class PsiMethodToPsiDoc {
|
||||
|
||||
private PsiMethodToPsiDoc() {}
|
||||
|
||||
@@ -69,7 +69,16 @@ class PsiMethodToPsiDoc {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static PsiDocComment propMethodDoc(@NotNull PsiMethod psiMethod, @NotNull PsiClass psiClass) {
|
||||
public static PsiField propMethodField(@NotNull PsiMethod psiMethod) {
|
||||
@Nullable PsiClass clazz = psiMethod.getContainingClass();
|
||||
if (clazz == null) {
|
||||
return null;
|
||||
}
|
||||
return propMethodClassField(psiMethod, clazz);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
static PsiField propMethodClassField(@NotNull PsiMethod psiMethod, @NotNull PsiClass psiClass) {
|
||||
@NotNull String name = psiMethod.getName();
|
||||
if (name.length() > 3 && (name.startsWith("get") || name.startsWith("set"))) {
|
||||
name = name.substring(3);
|
||||
@@ -82,7 +91,12 @@ class PsiMethodToPsiDoc {
|
||||
// Lower Case
|
||||
chars[0] += 32;
|
||||
name = String.valueOf(chars);
|
||||
@Nullable PsiField fieldByName = psiClass.findFieldByName(name, false);
|
||||
return psiClass.findFieldByName(name, false);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static PsiDocComment propMethodDoc(@NotNull PsiMethod psiMethod, @NotNull PsiClass psiClass) {
|
||||
@Nullable PsiField fieldByName = propMethodClassField(psiMethod, psiClass);
|
||||
if (fieldByName == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user