isEmpty | “扫黄”

This commit is contained in:
林万程
2023-08-31 08:03:37 +08:00
parent 54f102fdfb
commit c37148a56a
13 changed files with 20 additions and 17 deletions

View File

@@ -37,7 +37,7 @@ Show doc comment at the Project view Tree, line End, json, other
<h3>My Project</h3> <h3>My Project</h3>
<ul> <ul>
<li>Show doc comment at the Project view Tree, line End, json etc: <li>Show doc comment at the Project view Tree, line End, json etc.:
<a href="https://plugins.jetbrains.com/plugin/18553-show-comment">Show Comment</a> <a href="https://plugins.jetbrains.com/plugin/18553-show-comment">Show Comment</a>
</li> </li>
<li>Method call usage graph and maven dependency graph: <li>Method call usage graph and maven dependency graph:

View File

@@ -29,7 +29,7 @@ public class JavaTree {
if (docComment == null) { if (docComment == null) {
return null; return null;
} }
String s = JavaLangDoc.INSTANCE.docElementToStr(settingsInfo, docComment); @Nullable String s = JavaLangDoc.INSTANCE.docElementToStr(settingsInfo, docComment);
if (s != null && !DocSkip.skipDoc(settingsInfo, s)) { if (s != null && !DocSkip.skipDoc(settingsInfo, s)) {
return s; return s;
} }

View File

@@ -47,7 +47,7 @@ public class OwnerToPsiDocUtils {
return null; return null;
} }
@Nullable String name = psiPackage.getName(); @Nullable String name = psiPackage.getName();
if (name == null || name.length() == 0) { if (name == null || name.isEmpty()) {
return null; return null;
} }
@NotNull PsiDirectory[] psiDirectories = psiPackage.getDirectories(); @NotNull PsiDirectory[] psiDirectories = psiPackage.getDirectories();

View File

@@ -27,6 +27,9 @@ public class PsiClassUtils {
return PsiClass.EMPTY_ARRAY; return PsiClass.EMPTY_ARRAY;
} }
String className = matcher.group(); String className = matcher.group();
if (className == null) {
return PsiClass.EMPTY_ARRAY;
}
@NotNull PsiClass[] psiClasses = nameToClass(className, project); @NotNull PsiClass[] psiClasses = nameToClass(className, project);
if (psiClasses.length != 0) { if (psiClasses.length != 0) {
return psiClasses; return psiClasses;

View File

@@ -15,7 +15,7 @@ class PsiMethodToPsiDoc {
@Nullable @Nullable
static PsiDocComment methodSupperNewPropDoc(@NotNull PsiMethod psiMethod) { static PsiDocComment methodSupperNewPropDoc(@NotNull PsiMethod psiMethod) {
// .class // .class
PsiElement navElement = null; @Nullable PsiElement navElement;
try { try {
navElement = psiMethod.getNavigationElement(); navElement = psiMethod.getNavigationElement();
} catch (Exception e) { } catch (Exception e) {

View File

@@ -38,7 +38,7 @@ public class LineExt {
return null; return null;
} }
@Nullable Pattern pattern = ConfCache.pattern(lineInfo.project, keyMap, path); @Nullable Pattern pattern = ConfCache.pattern(lineInfo.project, keyMap, path);
if (pattern == null || pattern.pattern().length() == 0) { if (pattern == null || pattern.pattern().isEmpty()) {
return null; return null;
} }
@NotNull Map<String, Map<String, List<String>>> docMap = ConfCache.docMap(path, name, ext); @NotNull Map<String, Map<String, List<String>>> docMap = ConfCache.docMap(path, name, ext);
@@ -100,7 +100,7 @@ public class LineExt {
@NotNull Map<String, Map<String, List<String>>> docMap, @NotNull Map<String, Map<String, List<String>>> docMap,
@NotNull Map<String, Map<String, List<String>>> treeMap) { @NotNull Map<String, Map<String, List<String>>> treeMap) {
word = word.trim(); word = word.trim();
if (word.length() == 0) { if (word.isEmpty()) {
return false; return false;
} }
@Nullable String wordDoc = GetFromDocMap.get(docMap, word); @Nullable String wordDoc = GetFromDocMap.get(docMap, word);

View File

@@ -31,7 +31,7 @@ class ConfFactory {
String key = list.get(0); String key = list.get(0);
if (key.startsWith("?")) { if (key.startsWith("?")) {
exclude.add(key.substring(1)); exclude.add(key.substring(1));
} else if (key.length() > 0 && !exclude.contains(key)) { } else if (!key.isEmpty() && !exclude.contains(key)) {
sb.append(key).append("|"); sb.append(key).append("|");
} }
} }

View File

@@ -36,13 +36,13 @@ public class TsvLoader {
@NotNull List<String> words = Splitter.on('\t').splitToList(line); @NotNull List<String> words = Splitter.on('\t').splitToList(line);
if (!words.isEmpty()) { if (!words.isEmpty()) {
String key = words.get(0); String key = words.get(0);
if (key.length() == 0) { if (key.isEmpty()) {
continue; continue;
} }
if (patternKey) { if (patternKey) {
key = StringEscapeUtils.unescapeJava(key); key = StringEscapeUtils.unescapeJava(key);
String del = DEL_PATTERN.matcher(key).replaceAll(""); String del = DEL_PATTERN.matcher(key).replaceAll("");
if (del.length() != 0) { if (!del.isEmpty()) {
key = del; key = del;
} }
} }

View File

@@ -177,7 +177,7 @@ public abstract class BaseLangDoc extends EditorLinePainter {
} }
@NotNull String cutDoc = DocFilter.cutDoc(s, lineInfo.appSettings, true); @NotNull String cutDoc = DocFilter.cutDoc(s, lineInfo.appSettings, true);
@NotNull String filterDoc = DocFilter.filterDoc(cutDoc, lineInfo.appSettings, lineInfo.projectSettings); @NotNull String filterDoc = DocFilter.filterDoc(cutDoc, lineInfo.appSettings, lineInfo.projectSettings);
if (filterDoc.trim().length() == 0) { if (filterDoc.trim().isEmpty()) {
return null; return null;
} }
return filterDoc; return filterDoc;

View File

@@ -31,14 +31,14 @@ public abstract class BaseTagLangDoc<DocElement> extends BaseLangDoc {
for (@NotNull String name : names) { for (@NotNull String name : names) {
appendTag(lineInfo, tagStrBuilder, docElement, name); appendTag(lineInfo, tagStrBuilder, docElement, name);
} }
if (desc.length() > 0) { if (!desc.isEmpty()) {
if (tagStrBuilder.length() > 0) { if (tagStrBuilder.length() > 0) {
tagStrBuilder.insert(0, " @ "); tagStrBuilder.insert(0, " @ ");
} }
tagStrBuilder.insert(0, desc); tagStrBuilder.insert(0, desc);
} }
@NotNull String text = tagStrBuilder.toString().trim(); @NotNull String text = tagStrBuilder.toString().trim();
if (text.length() == 0) { if (text.isEmpty()) {
return null; return null;
} }
return text; return text;

View File

@@ -42,7 +42,7 @@ public class DocFilter {
} }
s = s.trim(); s = s.trim();
sb.append(s); sb.append(s);
if (s.length() > 0) { if (!s.isEmpty()) {
sb.append(" "); sb.append(" ");
} }
lineCount++; lineCount++;
@@ -93,7 +93,7 @@ public class DocFilter {
*/ */
public static void addHtml(@NotNull StringBuilder sb, @NotNull String s) { public static void addHtml(@NotNull StringBuilder sb, @NotNull String s) {
@NotNull String deleteHtml = html2Text(s); @NotNull String deleteHtml = html2Text(s);
if (deleteHtml.length() > 0) { if (!deleteHtml.isEmpty()) {
sb.append(deleteHtml); sb.append(deleteHtml);
} }
} }

View File

@@ -52,14 +52,14 @@ public class DocSkip {
} }
static boolean include(@NotNull String text, @NotNull Pattern include) { static boolean include(@NotNull String text, @NotNull Pattern include) {
if (include.pattern().length() == 0) { if (include.pattern().isEmpty()) {
return true; return true;
} }
return include.matcher(text).find(); return include.matcher(text).find();
} }
static boolean exclude(@NotNull String text, @NotNull Pattern exclude) { static boolean exclude(@NotNull String text, @NotNull Pattern exclude) {
if (exclude.pattern().length() == 0) { if (exclude.pattern().isEmpty()) {
return false; return false;
} }
return exclude.matcher(text).find(); return exclude.matcher(text).find();

View File

@@ -34,7 +34,7 @@ Show doc comment at the Project view Tree, line End, json, other
<h3>My Project</h3> <h3>My Project</h3>
<ul> <ul>
<li>Show doc comment at the Project view Tree, line End, json etc: <li>Show doc comment at the Project view Tree, line End, json etc.:
<a href="https://plugins.jetbrains.com/plugin/18553-show-comment">Show Comment</a> <a href="https://plugins.jetbrains.com/plugin/18553-show-comment">Show Comment</a>
</li> </li>
<li>Method call usage graph and maven dependency graph: <li>Method call usage graph and maven dependency graph: