chore: rename resolve psiElement and add @NotNull/Nullable
This commit is contained in:
@@ -181,25 +181,25 @@ public abstract class BaseLangDoc extends EditorLinePainter {
|
|||||||
* static! byte to src, by language
|
* static! byte to src, by language
|
||||||
*/
|
*/
|
||||||
public static @Nullable <T extends SettingsInfo> String resolveDoc(@NotNull T info,
|
public static @Nullable <T extends SettingsInfo> String resolveDoc(@NotNull T info,
|
||||||
@NotNull PsiElement psiElement) {
|
@NotNull PsiElement resolve) {
|
||||||
try {
|
try {
|
||||||
if (!psiElement.isValid()) {
|
if (!resolve.isValid()) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
// byte to src
|
// byte to src
|
||||||
PsiElement navElement = psiElement.getNavigationElement();
|
PsiElement navElement = resolve.getNavigationElement();
|
||||||
if (navElement != null) {
|
if (navElement != null) {
|
||||||
psiElement = navElement;
|
resolve = navElement;
|
||||||
}
|
}
|
||||||
} catch (Throwable ignore) {
|
} catch (Throwable ignore) {
|
||||||
// ignore
|
// ignore
|
||||||
}
|
}
|
||||||
// support like java <-> kotlin
|
// support like java <-> kotlin
|
||||||
@Nullable BaseLangDoc langDoc = PsiElementTo.findLangDoc(psiElement);
|
@Nullable BaseLangDoc langDoc = PsiElementTo.findLangDoc(resolve);
|
||||||
if (langDoc == null) {
|
if (langDoc == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return langDoc.resolveDocPrint(info, psiElement);
|
return langDoc.resolveDocPrint(info, resolve);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ public class FirstDoc {
|
|||||||
private FirstDoc() {}
|
private FirstDoc() {}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public static String firstDoc(ProjectViewNode<?> node, @NotNull SettingsInfo info) {
|
public static String firstDoc(@NotNull ProjectViewNode<?> node, @NotNull SettingsInfo info) {
|
||||||
if (!info.appSettings.treeFirst) {
|
if (!info.appSettings.treeFirst) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -30,7 +30,7 @@ public class FirstDoc {
|
|||||||
if (virtualFile == null || !virtualFile.isValid() || virtualFile.isDirectory()) {
|
if (virtualFile == null || !virtualFile.isValid() || virtualFile.isDirectory()) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
Project project = node.getProject();
|
@Nullable Project project = node.getProject();
|
||||||
if (project == null) {
|
if (project == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -68,15 +68,15 @@ public class FirstDoc {
|
|||||||
if (doc.contains("opyright")) {
|
if (doc.contains("opyright")) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
String cutDoc = DocFilter.cutDoc(doc, info, true);
|
@NotNull String cutDoc = DocFilter.cutDoc(doc, info, true);
|
||||||
FirstDocToDirCache.indexDocToDirDoc(virtualFile, cutDoc);
|
FirstDocToDirCache.indexDocToDirDoc(virtualFile, cutDoc);
|
||||||
return cutDoc;
|
return cutDoc;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final Pattern COMMENT_PATTERN = Pattern.compile("<!--|/\\*|//|#(?!!)");
|
private static final Pattern COMMENT_PATTERN = Pattern.compile("<!--|/\\*|//|#(?!!)");
|
||||||
private static boolean notDoc(@NotNull PsiElement psiElement) {
|
private static boolean notDoc(@NotNull PsiElement psiElement) {
|
||||||
String text = PsiUnSaveUtils.getText(psiElement);
|
@NotNull String text = PsiUnSaveUtils.getText(psiElement);
|
||||||
Matcher matcher = COMMENT_PATTERN.matcher(text);
|
@NotNull Matcher matcher = COMMENT_PATTERN.matcher(text);
|
||||||
return !matcher.find();
|
return !matcher.find();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user