easy debug info.lineNumber: replace lineInfo/settingInfo/fileInfo to info

This commit is contained in:
林万程
2023-12-20 18:26:49 +08:00
parent 249a43a6e8
commit ed33a94fcc
25 changed files with 211 additions and 207 deletions

View File

@@ -30,18 +30,18 @@ public class JavaLangDoc extends BaseTagLangDoc<PsiDocComment> {
}
@Override
public boolean show(@NotNull LineInfo lineInfo) {
return lineInfo.appSettings.showLineEndCommentJava;
public boolean show(@NotNull LineInfo info) {
return info.appSettings.showLineEndCommentJava;
}
@Override
public @Nullable <T extends SettingsInfo> String treeDoc(@NotNull T settingsInfo, ProjectViewNode<?> node,
public @Nullable <T extends SettingsInfo> String treeDoc(@NotNull T info, ProjectViewNode<?> node,
@NotNull Project project) {
return JavaTree.treeDoc(settingsInfo, node, project);
return JavaTree.treeDoc(info, node, project);
}
@Override
protected @Nullable String refDoc(@NotNull LineInfo lineInfo, @NotNull PsiElement ref) {
protected @Nullable String refDoc(@NotNull LineInfo info, @NotNull PsiElement ref) {
if ("Override".equals(ref.getText())) {
@Nullable PsiMethod psiMethod = PsiTreeUtil.getParentOfType(ref, PsiMethod.class);
if (psiMethod == null) {
@@ -49,47 +49,47 @@ public class JavaLangDoc extends BaseTagLangDoc<PsiDocComment> {
}
// must supper
@Nullable PsiDocComment psiDocComment = OwnerToPsiDocUtils.supperMethodDoc(psiMethod);
return docElementToStr(lineInfo, psiDocComment);
return docElementToStr(info, psiDocComment);
}
if (lineInfo.appSettings.fromNew) {
if (info.appSettings.fromNew) {
PsiElement parent = ref.getParent();
if (parent instanceof PsiNewExpression) {
@NotNull PsiNewExpression psiNewExpression = (PsiNewExpression) parent;
try {
@Nullable PsiMethod resolve = psiNewExpression.resolveMethod();
if (resolve != null) {
return resolveDocPrint(lineInfo, resolve);
return resolveDocPrint(info, resolve);
}
} catch (Throwable ignore) {
// ignore
}
}
}
return super.refDoc(lineInfo, ref);
return super.refDoc(info, ref);
}
@Override
public @Nullable <T extends SettingsInfo> String resolveDocPrint(@NotNull T settingsInfo, @NotNull PsiElement resolve) {
@Nullable String resolveDocPrint = super.resolveDocPrint(settingsInfo, resolve);
public @Nullable <T extends SettingsInfo> String resolveDocPrint(@NotNull T info, @NotNull PsiElement resolve) {
@Nullable String resolveDocPrint = super.resolveDocPrint(info, resolve);
if (resolveDocPrint != null) {
return resolveDocPrint;
}
// no doc comment support get set
if (parseBaseComment(settingsInfo) && resolve instanceof PsiMethod) {
if (parseBaseComment(info) && resolve instanceof PsiMethod) {
@Nullable PsiField psiField = PsiMethodToPsiDoc.propMethodField((PsiMethod) resolve);
if (psiField != null) {
return super.resolveDocPrint(settingsInfo, psiField);
return super.resolveDocPrint(info, psiField);
}
}
if (settingsInfo.appSettings.fromParam && resolve instanceof PsiParameter) {
if (info.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;
protected <T extends SettingsInfo> boolean parseBaseComment(@NotNull T info) {
return info.appSettings.showLineEndCommentJavaBase;
}
@Nullable
@@ -118,18 +118,18 @@ public class JavaLangDoc extends BaseTagLangDoc<PsiDocComment> {
@Nullable
@Override
protected <T extends SettingsInfo> PsiDocComment toDocElement(@NotNull T settingsInfo,
protected <T extends SettingsInfo> PsiDocComment toDocElement(@NotNull T info,
@NotNull PsiElement resolve) {
if (resolve instanceof PsiDocCommentOwner) {
@NotNull PsiDocCommentOwner psiDocCommentOwner = (PsiDocCommentOwner) resolve;
return OwnerToPsiDocSkip.refDoc(settingsInfo, psiDocCommentOwner);
return OwnerToPsiDocSkip.refDoc(info, psiDocCommentOwner);
}
return null;
}
@NotNull
@Override
protected <T extends SettingsInfo> String descDoc(@NotNull T lineInfo, @NotNull PsiDocComment psiDocComment) {
protected <T extends SettingsInfo> String descDoc(@NotNull T info, @NotNull PsiDocComment psiDocComment) {
@NotNull StringBuilder sb = new StringBuilder();
int lineCount = 0;
@NotNull PsiElement[] elements = psiDocComment.getDescriptionElements();
@@ -137,7 +137,7 @@ public class JavaLangDoc extends BaseTagLangDoc<PsiDocComment> {
if (appendElementText(sb, element)) {
lineCount++;
}
if (DocFilter.lineCountOrLenOver(lineInfo, sb, lineCount)) {
if (DocFilter.lineCountOrLenOver(info, sb, lineCount)) {
break;
}
}
@@ -163,7 +163,7 @@ public class JavaLangDoc extends BaseTagLangDoc<PsiDocComment> {
}
@Override
protected <T extends SettingsInfo> void appendTag(@NotNull T lineInfo, @NotNull StringBuilder tagStrBuilder,
protected <T extends SettingsInfo> void appendTag(@NotNull T info, @NotNull StringBuilder tagStrBuilder,
@NotNull PsiDocComment psiDocComment, @NotNull String name) {
@NotNull PsiDocTag[] tags = psiDocComment.findTagsByName(name);
for (@NotNull PsiDocTag tag : tags) {

View File

@@ -23,21 +23,21 @@ public class JavaTree {
private JavaTree() {}
@Nullable
public static <T extends SettingsInfo> String treeDoc(@NotNull T settingsInfo, ProjectViewNode<?> node,
public static <T extends SettingsInfo> String treeDoc(@NotNull T info, ProjectViewNode<?> node,
@NotNull Project project) {
@Nullable PsiDocComment docComment = nodeDoc(settingsInfo, node, project);
@Nullable PsiDocComment docComment = nodeDoc(info, node, project);
if (docComment == null) {
return null;
}
@Nullable String s = JavaLangDoc.INSTANCE.docElementToStr(settingsInfo, docComment);
if (s != null && !DocSkip.skipDoc(settingsInfo, s)) {
@Nullable String s = JavaLangDoc.INSTANCE.docElementToStr(info, docComment);
if (s != null && !DocSkip.skipDoc(info, s)) {
return s;
}
return null;
}
@Nullable
static <T extends SettingsInfo> PsiDocComment nodeDoc(@NotNull T settingsInfo, ProjectViewNode<?> node,
static <T extends SettingsInfo> PsiDocComment nodeDoc(@NotNull T info, ProjectViewNode<?> node,
@NotNull Project project) {
if (node instanceof PsiFileNode) {
PsiFile psiFile = ((PsiFileNode) node).getValue();
@@ -56,7 +56,7 @@ public class JavaTree {
if (type instanceof PsiClassReferenceType) {
@NotNull PsiClassReferenceType psiClassReferenceType = (PsiClassReferenceType) type;
@NotNull PsiJavaCodeReferenceElement reference = psiClassReferenceType.getReference();
return NewCallRefToPsiDoc.javaCodeDoc(settingsInfo, reference);
return NewCallRefToPsiDoc.javaCodeDoc(info, reference);
}
}

View File

@@ -29,18 +29,18 @@ public class KotlinLangDoc extends BaseTagLangDoc<KDocSection> {
}
@Override
public boolean show(@NotNull LineInfo lineInfo) {
return lineInfo.appSettings.showLineEndCommentKotlin;
public boolean show(@NotNull LineInfo info) {
return info.appSettings.showLineEndCommentKotlin;
}
@Override
protected <T extends SettingsInfo> boolean parseBaseComment(@NotNull T settingsInfo) {
return settingsInfo.appSettings.showLineEndCommentKotlinBase;
protected <T extends SettingsInfo> boolean parseBaseComment(@NotNull T info) {
return info.appSettings.showLineEndCommentKotlinBase;
}
@Override
@Nullable
protected <T extends SettingsInfo> KDocSection toDocElement(@NotNull T settingsInfo, @NotNull PsiElement resolve) {
protected <T extends SettingsInfo> KDocSection toDocElement(@NotNull T info, @NotNull PsiElement resolve) {
if (resolve instanceof PsiPackageBase) {
return null;
}
@@ -53,18 +53,18 @@ public class KotlinLangDoc extends BaseTagLangDoc<KDocSection> {
@NotNull
@Override
protected <T extends SettingsInfo> String descDoc(@NotNull T lineInfo, @NotNull KDocSection kDocSection) {
protected <T extends SettingsInfo> String descDoc(@NotNull T info, @NotNull KDocSection kDocSection) {
@NotNull String content = kDocSection.getContent();
return DocFilter.cutDoc(content, lineInfo, false);
return DocFilter.cutDoc(content, info, false);
}
@Override
protected <T extends SettingsInfo> void appendTag(@NotNull T lineInfo, @NotNull StringBuilder tagStrBuilder,
protected <T extends SettingsInfo> void appendTag(@NotNull T info, @NotNull StringBuilder tagStrBuilder,
@NotNull KDocSection kDocSection, @NotNull String name) {
@NotNull List<KDocTag> tags = kDocSection.findTagsByName(name);
for (@NotNull KDocTag tag : tags) {
@NotNull String content = tag.getContent();
@NotNull String cutDoc = DocFilter.cutDoc(content, lineInfo, false);
@NotNull String cutDoc = DocFilter.cutDoc(content, info, false);
tagStrBuilder.append(cutDoc);
}
}

View File

@@ -16,7 +16,7 @@ public class NewCallRefToPsiDoc {
private NewCallRefToPsiDoc() {}
@Nullable
public static <T extends SettingsInfo> PsiDocComment javaCodeDoc(@NotNull T settingsInfo,
public static <T extends SettingsInfo> PsiDocComment javaCodeDoc(@NotNull T info,
@Nullable PsiJavaCodeReferenceElement ref) {
if (ref == null) {
return null;
@@ -28,7 +28,7 @@ public class NewCallRefToPsiDoc {
// ignore
}
if (resolve instanceof PsiDocCommentOwner) {
return OwnerToPsiDocSkip.refDoc(settingsInfo, ((PsiDocCommentOwner) resolve));
return OwnerToPsiDocSkip.refDoc(info, ((PsiDocCommentOwner) resolve));
}
return null;
}

View File

@@ -16,17 +16,17 @@ public class OwnerToPsiDocSkip {
private OwnerToPsiDocSkip() {}
@Nullable
public static <T extends SettingsInfo> PsiDocComment refDoc(@NotNull T settingsInfo,
public static <T extends SettingsInfo> PsiDocComment refDoc(@NotNull T info,
@Nullable PsiDocCommentOwner docOwner) {
if (docOwner == null) {
return null;
}
if (SkipUtils.skipSign(settingsInfo, docOwner)) {
if (SkipUtils.skipSign(info, docOwner)) {
return null;
}
@Nullable PsiDocComment docComment = docOwner instanceof PsiMethod
? OwnerToPsiDocUtils.methodDoc(((PsiMethod) docOwner))
: OwnerToPsiDocUtils.srcOrByteCodeDoc(docOwner);
return SkipUtils.skipDoc(settingsInfo, docComment);
return SkipUtils.skipDoc(info, docComment);
}
}

View File

@@ -15,20 +15,20 @@ class SkipUtils {
private SkipUtils() {}
static <T extends SettingsInfo> boolean skipSign(@NotNull T settingsInfo, PsiElement psiElement) {
@Nullable String text = psiName(settingsInfo, psiElement);
static <T extends SettingsInfo> boolean skipSign(@NotNull T info, PsiElement psiElement) {
@Nullable String text = psiName(info, psiElement);
if (text == null) {
return true;
}
return DocSkip.skipSign(settingsInfo, text);
return DocSkip.skipSign(info, text);
}
@Nullable
private static <T extends SettingsInfo> String psiName(@NotNull T settingsInfo, @Nullable PsiElement psiElement) {
private static <T extends SettingsInfo> String psiName(@NotNull T info, @Nullable PsiElement psiElement) {
if (psiElement instanceof PsiClass) {
@NotNull PsiClass psiClass = (PsiClass) psiElement;
if (settingsInfo.funcEnum == FuncEnum.LINE
&& settingsInfo.appSettings.skipAnnotation && psiClass.isAnnotationType()) {
if (info.funcEnum == FuncEnum.LINE
&& info.appSettings.skipAnnotation && psiClass.isAnnotationType()) {
return null;
}
return psiClass.getQualifiedName();
@@ -53,15 +53,15 @@ class SkipUtils {
}
@Nullable
static <T extends SettingsInfo> PsiDocComment skipDoc(@NotNull T settingsInfo, @Nullable PsiDocComment doc) {
static <T extends SettingsInfo> PsiDocComment skipDoc(@NotNull T info, @Nullable PsiDocComment doc) {
if (doc == null) {
return null;
}
if (settingsInfo.appSettings.skipBlank && isBlank(doc)) {
if (info.appSettings.skipBlank && isBlank(doc)) {
return null;
}
String text = doc.getText();
boolean skip = DocSkip.skipDoc(settingsInfo, text);
boolean skip = DocSkip.skipDoc(info, text);
return skip ? null : doc;
}