fix(JavaLangDoc): skipSign not effect in when ☑ // Java
This commit is contained in:
@@ -24,6 +24,7 @@ import io.github.linwancen.plugin.show.java.doc.NewDoc;
|
|||||||
import io.github.linwancen.plugin.show.java.doc.ParamDoc;
|
import io.github.linwancen.plugin.show.java.doc.ParamDoc;
|
||||||
import io.github.linwancen.plugin.show.java.doc.PsiMethodToPsiDoc;
|
import io.github.linwancen.plugin.show.java.doc.PsiMethodToPsiDoc;
|
||||||
import io.github.linwancen.plugin.show.java.line.OwnerToPsiDocSkip;
|
import io.github.linwancen.plugin.show.java.line.OwnerToPsiDocSkip;
|
||||||
|
import io.github.linwancen.plugin.show.java.line.SkipUtils;
|
||||||
import io.github.linwancen.plugin.show.lang.base.BaseTagLangDoc;
|
import io.github.linwancen.plugin.show.lang.base.BaseTagLangDoc;
|
||||||
import io.github.linwancen.plugin.show.lang.base.DocFilter;
|
import io.github.linwancen.plugin.show.lang.base.DocFilter;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
@@ -80,6 +81,9 @@ public class JavaLangDoc extends BaseTagLangDoc<PsiDocComment> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @Nullable <T extends SettingsInfo> String resolveDocPrint(@NotNull T info, @NotNull PsiElement resolve) {
|
public @Nullable <T extends SettingsInfo> String resolveDocPrint(@NotNull T info, @NotNull PsiElement resolve) {
|
||||||
|
if (SkipUtils.skipSign(info, resolve)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
@Nullable String resolveDocPrint = super.resolveDocPrint(info, resolve);
|
@Nullable String resolveDocPrint = super.resolveDocPrint(info, resolve);
|
||||||
if (resolveDocPrint != null) {
|
if (resolveDocPrint != null) {
|
||||||
return resolveDocPrint;
|
return resolveDocPrint;
|
||||||
@@ -147,7 +151,7 @@ public class JavaLangDoc extends BaseTagLangDoc<PsiDocComment> {
|
|||||||
if (element instanceof PsiWhiteSpace && sb.length() > 0) {
|
if (element instanceof PsiWhiteSpace && sb.length() > 0) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
PsiElement[] children = element.getChildren();
|
@NotNull PsiElement[] children = element.getChildren();
|
||||||
if (children.length > 0) {
|
if (children.length > 0) {
|
||||||
if (children.length >= 3) {
|
if (children.length >= 3) {
|
||||||
DocFilter.addHtml(sb, children[children.length - 2].getText());
|
DocFilter.addHtml(sb, children[children.length - 2].getText());
|
||||||
@@ -167,7 +171,7 @@ public class JavaLangDoc extends BaseTagLangDoc<PsiDocComment> {
|
|||||||
if (value != null) {
|
if (value != null) {
|
||||||
DocFilter.addHtml(tagStrBuilder, value.getText());
|
DocFilter.addHtml(tagStrBuilder, value.getText());
|
||||||
} else {
|
} else {
|
||||||
PsiElement[] dataElements = tag.getDataElements();
|
@NotNull PsiElement[] dataElements = tag.getDataElements();
|
||||||
if (dataElements.length > 0) {
|
if (dataElements.length > 0) {
|
||||||
DocFilter.addHtml(tagStrBuilder, dataElements[0].getText());
|
DocFilter.addHtml(tagStrBuilder, dataElements[0].getText());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ public class ScalaLangDoc extends JavaLangDoc {
|
|||||||
@NotNull PsiElement resolve) {
|
@NotNull PsiElement resolve) {
|
||||||
if (resolve instanceof PsiDocCommentOwner) {
|
if (resolve instanceof PsiDocCommentOwner) {
|
||||||
@NotNull PsiDocCommentOwner psiDocCommentOwner = (PsiDocCommentOwner) resolve;
|
@NotNull PsiDocCommentOwner psiDocCommentOwner = (PsiDocCommentOwner) resolve;
|
||||||
return OwnerToPsiDocSkip.refDocWithOutSkip(info, psiDocCommentOwner);
|
return OwnerToPsiDocSkip.refDocWithOutSkip(psiDocCommentOwner);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -55,8 +55,8 @@ public class ScalaLangDoc extends JavaLangDoc {
|
|||||||
@Override
|
@Override
|
||||||
protected <T extends SettingsInfo> String descDoc(@NotNull T info, @NotNull PsiDocComment psiDocComment) {
|
protected <T extends SettingsInfo> String descDoc(@NotNull T info, @NotNull PsiDocComment psiDocComment) {
|
||||||
@NotNull PsiElement[] elements = psiDocComment.getChildren();
|
@NotNull PsiElement[] elements = psiDocComment.getChildren();
|
||||||
StringBuilder sb = new StringBuilder();
|
@NotNull StringBuilder sb = new StringBuilder();
|
||||||
for (PsiElement element : elements) {
|
for (@NotNull PsiElement element : elements) {
|
||||||
if (!(element instanceof PsiDocTag)) {
|
if (!(element instanceof PsiDocTag)) {
|
||||||
sb.append(element.getText());
|
sb.append(element.getText());
|
||||||
}
|
}
|
||||||
@@ -70,7 +70,7 @@ public class ScalaLangDoc extends JavaLangDoc {
|
|||||||
@NotNull PsiDocTag[] tags = psiDocComment.findTagsByName("@" + name);
|
@NotNull PsiDocTag[] tags = psiDocComment.findTagsByName("@" + name);
|
||||||
for (@NotNull PsiDocTag tag : tags) {
|
for (@NotNull PsiDocTag tag : tags) {
|
||||||
if (tag instanceof ScDocTag) {
|
if (tag instanceof ScDocTag) {
|
||||||
ScDocTag scDocTag = (ScDocTag) tag;
|
@NotNull ScDocTag scDocTag = (ScDocTag) tag;
|
||||||
String doc = scDocTag.getCommentDataText();
|
String doc = scDocTag.getCommentDataText();
|
||||||
DocFilter.addHtml(tagStrBuilder, doc);
|
DocFilter.addHtml(tagStrBuilder, doc);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,7 +36,8 @@ public class NewCallRefToPsiDoc {
|
|||||||
} catch (Throwable ignore) {
|
} catch (Throwable ignore) {
|
||||||
// ignore
|
// ignore
|
||||||
}
|
}
|
||||||
return OwnerToPsiDocSkip.refDoc(info, ((PsiDocCommentOwner) resolve));
|
@NotNull PsiDocCommentOwner psiDocCommentOwner = (PsiDocCommentOwner) resolve;
|
||||||
|
return OwnerToPsiDocSkip.refDoc(info, psiDocCommentOwner);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,22 +17,14 @@ public class OwnerToPsiDocSkip {
|
|||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public static <T extends SettingsInfo> PsiDocComment refDoc(@NotNull T info,
|
public static <T extends SettingsInfo> PsiDocComment refDoc(@NotNull T info,
|
||||||
@Nullable PsiDocCommentOwner docOwner) {
|
@NotNull PsiDocCommentOwner docOwner) {
|
||||||
return SkipUtils.skipDoc(info, refDocWithOutSkip(info, docOwner));
|
return SkipUtils.skipDoc(info, refDocWithOutSkip(docOwner));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public static <T extends SettingsInfo> PsiDocComment refDocWithOutSkip(@NotNull T info,
|
public static <T extends SettingsInfo> PsiDocComment refDocWithOutSkip(@NotNull PsiDocCommentOwner docOwner) {
|
||||||
@Nullable PsiDocCommentOwner docOwner) {
|
return docOwner instanceof PsiMethod
|
||||||
if (docOwner == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (SkipUtils.skipSign(info, docOwner)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
@Nullable PsiDocComment docComment = docOwner instanceof PsiMethod
|
|
||||||
? PsiMethodToPsiDoc.methodSupperNewPropDoc(((PsiMethod) docOwner))
|
? PsiMethodToPsiDoc.methodSupperNewPropDoc(((PsiMethod) docOwner))
|
||||||
: docOwner.getDocComment();
|
: docOwner.getDocComment();
|
||||||
return docComment;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,14 +11,14 @@ import org.apache.commons.lang3.StringUtils;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
class SkipUtils {
|
public class SkipUtils {
|
||||||
|
|
||||||
private SkipUtils() {}
|
private SkipUtils() {}
|
||||||
|
|
||||||
static <T extends SettingsInfo> boolean skipSign(@NotNull T info, PsiElement psiElement) {
|
public static <T extends SettingsInfo> boolean skipSign(@NotNull T info, PsiElement psiElement) {
|
||||||
@Nullable String text = psiName(info, psiElement);
|
@Nullable String text = psiName(info, psiElement);
|
||||||
if (text == null) {
|
if (text == null) {
|
||||||
return true;
|
return false;
|
||||||
}
|
}
|
||||||
return DocSkip.skipSign(info, text);
|
return DocSkip.skipSign(info, text);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user