chore: rename resolve psiElement and add @NotNull/Nullable

This commit is contained in:
林万程
2025-12-02 07:19:15 +08:00
parent fa0c17e992
commit 99ae7f7991
2 changed files with 11 additions and 11 deletions

View File

@@ -181,25 +181,25 @@ public abstract class BaseLangDoc extends EditorLinePainter {
* static! byte to src, by language
*/
public static @Nullable <T extends SettingsInfo> String resolveDoc(@NotNull T info,
@NotNull PsiElement psiElement) {
@NotNull PsiElement resolve) {
try {
if (!psiElement.isValid()) {
if (!resolve.isValid()) {
return null;
}
// byte to src
PsiElement navElement = psiElement.getNavigationElement();
PsiElement navElement = resolve.getNavigationElement();
if (navElement != null) {
psiElement = navElement;
resolve = navElement;
}
} catch (Throwable ignore) {
// ignore
}
// support like java <-> kotlin
@Nullable BaseLangDoc langDoc = PsiElementTo.findLangDoc(psiElement);
@Nullable BaseLangDoc langDoc = PsiElementTo.findLangDoc(resolve);
if (langDoc == null) {
return null;
}
return langDoc.resolveDocPrint(info, psiElement);
return langDoc.resolveDocPrint(info, resolve);
}
/**

View File

@@ -22,7 +22,7 @@ public class FirstDoc {
private FirstDoc() {}
@Nullable
public static String firstDoc(ProjectViewNode<?> node, @NotNull SettingsInfo info) {
public static String firstDoc(@NotNull ProjectViewNode<?> node, @NotNull SettingsInfo info) {
if (!info.appSettings.treeFirst) {
return null;
}
@@ -30,7 +30,7 @@ public class FirstDoc {
if (virtualFile == null || !virtualFile.isValid() || virtualFile.isDirectory()) {
return null;
}
Project project = node.getProject();
@Nullable Project project = node.getProject();
if (project == null) {
return null;
}
@@ -68,15 +68,15 @@ public class FirstDoc {
if (doc.contains("opyright")) {
return null;
}
String cutDoc = DocFilter.cutDoc(doc, info, true);
@NotNull String cutDoc = DocFilter.cutDoc(doc, info, true);
FirstDocToDirCache.indexDocToDirDoc(virtualFile, cutDoc);
return cutDoc;
}
private static final Pattern COMMENT_PATTERN = Pattern.compile("<!--|/\\*|//|#(?!!)");
private static boolean notDoc(@NotNull PsiElement psiElement) {
String text = PsiUnSaveUtils.getText(psiElement);
Matcher matcher = COMMENT_PATTERN.matcher(text);
@NotNull String text = PsiUnSaveUtils.getText(psiElement);
@NotNull Matcher matcher = COMMENT_PATTERN.matcher(text);
return !matcher.find();
}
}