@Null Annotations, etc
This commit is contained in:
@@ -34,27 +34,28 @@ public class JavaLangDoc extends BaseTagLangDoc<PsiDocComment> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable <T extends SettingsInfo> String treeDoc(T settingsInfo, ProjectViewNode<?> node, Project project) {
|
||||
public @Nullable <T extends SettingsInfo> String treeDoc(@NotNull T settingsInfo, ProjectViewNode<?> node,
|
||||
@NotNull Project project) {
|
||||
return JavaTree.treeDoc(settingsInfo, node, project);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected @Nullable <T extends SettingsInfo> String refDoc(@NotNull T lineInfo, @NotNull PsiElement ref) {
|
||||
if ("Override".equals(ref.getText())) {
|
||||
PsiMethod psiMethod = PsiTreeUtil.getParentOfType(ref, PsiMethod.class);
|
||||
@Nullable PsiMethod psiMethod = PsiTreeUtil.getParentOfType(ref, PsiMethod.class);
|
||||
if (psiMethod == null) {
|
||||
return null;
|
||||
}
|
||||
// must supper
|
||||
PsiDocComment psiDocComment = OwnerToPsiDocUtils.supperMethodDoc(psiMethod);
|
||||
@Nullable PsiDocComment psiDocComment = OwnerToPsiDocUtils.supperMethodDoc(psiMethod);
|
||||
return docElementToStr(lineInfo, psiDocComment);
|
||||
}
|
||||
if (lineInfo.appSettings.fromNew) {
|
||||
PsiElement parent = ref.getParent();
|
||||
if (parent instanceof PsiNewExpression) {
|
||||
PsiNewExpression psiNewExpression = (PsiNewExpression) parent;
|
||||
@NotNull PsiNewExpression psiNewExpression = (PsiNewExpression) parent;
|
||||
try {
|
||||
PsiMethod resolve = psiNewExpression.resolveMethod();
|
||||
@Nullable PsiMethod resolve = psiNewExpression.resolveMethod();
|
||||
if (resolve != null) {
|
||||
return resolveDocPrint(lineInfo, resolve);
|
||||
}
|
||||
@@ -68,7 +69,7 @@ public class JavaLangDoc extends BaseTagLangDoc<PsiDocComment> {
|
||||
|
||||
@Override
|
||||
public @Nullable <T extends SettingsInfo> String resolveDocPrint(@NotNull T lineInfo, @NotNull PsiElement resolve) {
|
||||
String resolveDocPrint = super.resolveDocPrint(lineInfo, resolve);
|
||||
@Nullable String resolveDocPrint = super.resolveDocPrint(lineInfo, resolve);
|
||||
if (resolveDocPrint != null) {
|
||||
return resolveDocPrint;
|
||||
}
|
||||
@@ -80,20 +81,20 @@ public class JavaLangDoc extends BaseTagLangDoc<PsiDocComment> {
|
||||
|
||||
@Nullable
|
||||
private String paramDoc(@NotNull PsiParameter psiParameter) {
|
||||
PsiMethod method = PsiTreeUtil.getParentOfType(psiParameter, PsiMethod.class);
|
||||
@Nullable PsiMethod method = PsiTreeUtil.getParentOfType(psiParameter, PsiMethod.class);
|
||||
if (method == null) {
|
||||
return null;
|
||||
}
|
||||
PsiDocComment psiDocComment = OwnerToPsiDocUtils.methodDoc(method);
|
||||
@Nullable PsiDocComment psiDocComment = OwnerToPsiDocUtils.methodDoc(method);
|
||||
if (psiDocComment == null) {
|
||||
return null;
|
||||
}
|
||||
String name = psiParameter.getName();
|
||||
PsiDocTag[] params = psiDocComment.findTagsByName("param");
|
||||
for (PsiDocTag param : params) {
|
||||
PsiDocTagValue value = param.getValueElement();
|
||||
@NotNull String name = psiParameter.getName();
|
||||
@NotNull PsiDocTag[] params = psiDocComment.findTagsByName("param");
|
||||
for (@NotNull PsiDocTag param : params) {
|
||||
@Nullable PsiDocTagValue value = param.getValueElement();
|
||||
if (value != null && name.equals(value.getText())) {
|
||||
PsiElement[] dataElements = param.getDataElements();
|
||||
@NotNull PsiElement[] dataElements = param.getDataElements();
|
||||
if (dataElements.length > 1) {
|
||||
return dataElements[1].getText();
|
||||
}
|
||||
@@ -106,7 +107,7 @@ public class JavaLangDoc extends BaseTagLangDoc<PsiDocComment> {
|
||||
@Override
|
||||
protected PsiDocComment toDocElement(@NotNull PsiElement resolve) {
|
||||
if (resolve instanceof PsiDocCommentOwner) {
|
||||
PsiDocCommentOwner psiDocCommentOwner = (PsiDocCommentOwner) resolve;
|
||||
@NotNull PsiDocCommentOwner psiDocCommentOwner = (PsiDocCommentOwner) resolve;
|
||||
return OwnerToPsiDocSkip.refDoc(psiDocCommentOwner);
|
||||
}
|
||||
return null;
|
||||
@@ -115,9 +116,9 @@ public class JavaLangDoc extends BaseTagLangDoc<PsiDocComment> {
|
||||
@NotNull
|
||||
@Override
|
||||
protected <T extends SettingsInfo> String descDoc(@NotNull T lineInfo, @NotNull PsiDocComment psiDocComment) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
@NotNull StringBuilder sb = new StringBuilder();
|
||||
int lineCount = 0;
|
||||
PsiElement[] elements = psiDocComment.getDescriptionElements();
|
||||
@NotNull PsiElement[] elements = psiDocComment.getDescriptionElements();
|
||||
for (PsiElement element : elements) {
|
||||
if (appendElementText(sb, element)) {
|
||||
lineCount++;
|
||||
@@ -132,14 +133,14 @@ public class JavaLangDoc extends BaseTagLangDoc<PsiDocComment> {
|
||||
/**
|
||||
* @return is new line
|
||||
*/
|
||||
private static boolean appendElementText(StringBuilder sb, PsiElement element) {
|
||||
private static boolean appendElementText(@NotNull StringBuilder sb, PsiElement element) {
|
||||
if (element instanceof PsiDocToken) {
|
||||
PsiDocToken psiDocToken = (PsiDocToken) element;
|
||||
@NotNull PsiDocToken psiDocToken = (PsiDocToken) element;
|
||||
DocFilter.addHtml(sb, psiDocToken.getText());
|
||||
}
|
||||
if (element instanceof PsiInlineDocTag) {
|
||||
PsiInlineDocTag psiInlineDocTag = (PsiInlineDocTag) element;
|
||||
PsiElement[] children = psiInlineDocTag.getChildren();
|
||||
@NotNull PsiInlineDocTag psiInlineDocTag = (PsiInlineDocTag) element;
|
||||
@NotNull PsiElement[] children = psiInlineDocTag.getChildren();
|
||||
if (children.length > 3) {
|
||||
DocFilter.addHtml(sb, children[3].getText());
|
||||
}
|
||||
@@ -150,10 +151,10 @@ public class JavaLangDoc extends BaseTagLangDoc<PsiDocComment> {
|
||||
@Override
|
||||
protected <T extends SettingsInfo> void appendTag(@NotNull T lineInfo, @NotNull StringBuilder tagStrBuilder,
|
||||
@NotNull PsiDocComment psiDocComment, @NotNull String name) {
|
||||
PsiDocTag[] tags = psiDocComment.findTagsByName(name);
|
||||
for (PsiDocTag tag : tags) {
|
||||
@NotNull PsiDocTag[] tags = psiDocComment.findTagsByName(name);
|
||||
for (@NotNull PsiDocTag tag : tags) {
|
||||
// @see @param should use getDataElements()
|
||||
PsiDocTagValue value = tag.getValueElement();
|
||||
@Nullable PsiDocTagValue value = tag.getValueElement();
|
||||
if (value != null) {
|
||||
DocFilter.addHtml(tagStrBuilder, value.getText());
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ import io.github.linwancen.plugin.show.bean.SettingsInfo;
|
||||
import io.github.linwancen.plugin.show.java.doc.OwnerToPsiDocUtils;
|
||||
import io.github.linwancen.plugin.show.java.line.NewCallRefToPsiDoc;
|
||||
import io.github.linwancen.plugin.show.settings.AppSettingsState;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class JavaTree {
|
||||
@@ -21,8 +22,9 @@ public class JavaTree {
|
||||
private JavaTree() {}
|
||||
|
||||
@Nullable
|
||||
public static <T extends SettingsInfo> String treeDoc(T settingsInfo, ProjectViewNode<?> node, Project project) {
|
||||
PsiDocComment docComment = nodeDoc(node, project);
|
||||
public static <T extends SettingsInfo> String treeDoc(@NotNull T settingsInfo, ProjectViewNode<?> node,
|
||||
@NotNull Project project) {
|
||||
@Nullable PsiDocComment docComment = nodeDoc(node, project);
|
||||
if (docComment == null) {
|
||||
return null;
|
||||
}
|
||||
@@ -30,7 +32,7 @@ public class JavaTree {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
static PsiDocComment nodeDoc(ProjectViewNode<?> node, Project project) {
|
||||
static PsiDocComment nodeDoc(ProjectViewNode<?> node, @NotNull Project project) {
|
||||
if (node instanceof PsiFileNode) {
|
||||
PsiFile psiFile = ((PsiFileNode) node).getValue();
|
||||
return OwnerToPsiDocUtils.fileDoc(psiFile);
|
||||
@@ -44,26 +46,26 @@ public class JavaTree {
|
||||
// On Show Members
|
||||
PsiField psiField = ((PsiFieldNode) node).getValue();
|
||||
// for @Autowire Bean
|
||||
PsiType type = psiField.getType();
|
||||
@NotNull PsiType type = psiField.getType();
|
||||
if (type instanceof PsiClassReferenceType) {
|
||||
PsiClassReferenceType psiClassReferenceType = (PsiClassReferenceType) type;
|
||||
PsiJavaCodeReferenceElement reference = psiClassReferenceType.getReference();
|
||||
@NotNull PsiClassReferenceType psiClassReferenceType = (PsiClassReferenceType) type;
|
||||
@NotNull PsiJavaCodeReferenceElement reference = psiClassReferenceType.getReference();
|
||||
return NewCallRefToPsiDoc.javaCodeDoc(reference);
|
||||
}
|
||||
}
|
||||
|
||||
if (node instanceof PackageElementNode) {
|
||||
// On Packages View
|
||||
PsiPackage psiPackage = ((PackageElementNode) node).getValue().getPackage();
|
||||
@NotNull PsiPackage psiPackage = ((PackageElementNode) node).getValue().getPackage();
|
||||
return packageDoc(psiPackage);
|
||||
}
|
||||
|
||||
// On Packages View, Project Files View
|
||||
VirtualFile virtualFile = node.getVirtualFile();
|
||||
@Nullable VirtualFile virtualFile = node.getVirtualFile();
|
||||
if (virtualFile == null || !virtualFile.isDirectory()) {
|
||||
return null;
|
||||
}
|
||||
PsiDirectory psiDirectory = PsiManager.getInstance(project).findDirectory(virtualFile);
|
||||
@Nullable PsiDirectory psiDirectory = PsiManager.getInstance(project).findDirectory(virtualFile);
|
||||
if (psiDirectory == null) {
|
||||
return null;
|
||||
}
|
||||
@@ -71,17 +73,17 @@ public class JavaTree {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
static PsiDocComment dirDoc(PsiDirectory child) {
|
||||
static PsiDocComment dirDoc(@NotNull PsiDirectory child) {
|
||||
while (true) {
|
||||
PsiDocComment docComment = OwnerToPsiDocUtils.dirDoc(child);
|
||||
@Nullable PsiDocComment docComment = OwnerToPsiDocUtils.dirDoc(child);
|
||||
if (docComment != null) {
|
||||
return docComment;
|
||||
}
|
||||
AppSettingsState instance = AppSettingsState.getInstance();
|
||||
@NotNull AppSettingsState instance = AppSettingsState.getInstance();
|
||||
if (!instance.compact) {
|
||||
return null;
|
||||
}
|
||||
PsiDirectory parent = child.getParent();
|
||||
@Nullable PsiDirectory parent = child.getParent();
|
||||
if (parent == null) {
|
||||
return null;
|
||||
}
|
||||
@@ -93,13 +95,13 @@ public class JavaTree {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
static PsiDocComment packageDoc(PsiPackage child) {
|
||||
static PsiDocComment packageDoc(@NotNull PsiPackage child) {
|
||||
while (true) {
|
||||
PsiDocComment docComment = OwnerToPsiDocUtils.packageDoc(child);
|
||||
@Nullable PsiDocComment docComment = OwnerToPsiDocUtils.packageDoc(child);
|
||||
if (docComment != null) {
|
||||
return docComment;
|
||||
}
|
||||
PsiPackage parent = child.getParentPackage();
|
||||
@Nullable PsiPackage parent = child.getParentPackage();
|
||||
if (parent == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ import com.intellij.util.ProcessingContext;
|
||||
import io.github.linwancen.plugin.show.java.doc.PsiClassUtils;
|
||||
import io.github.linwancen.plugin.show.jump.JsonRef;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
@@ -25,7 +26,8 @@ public class JsonJumpJava extends PsiReferenceContributor {
|
||||
@Override
|
||||
public @NotNull PsiReference[] getReferencesByElement(@NotNull PsiElement element,
|
||||
@NotNull ProcessingContext context) {
|
||||
JsonProperty jsonProp = PsiTreeUtil.getParentOfType(element, JsonProperty.class, true);
|
||||
@Nullable JsonProperty jsonProp = PsiTreeUtil.getParentOfType(
|
||||
element, JsonProperty.class, true);
|
||||
if (jsonProp == null) {
|
||||
return PsiReference.EMPTY_ARRAY;
|
||||
}
|
||||
@@ -34,15 +36,15 @@ public class JsonJumpJava extends PsiReferenceContributor {
|
||||
return PsiReference.EMPTY_ARRAY;
|
||||
}
|
||||
|
||||
Project project = element.getProject();
|
||||
List<PsiField> psiFields = new ArrayList<>();
|
||||
List<PsiField> tips = new ArrayList<>();
|
||||
PsiClass[] psiClasses = PsiClassUtils.encClass(virtualFile, project);
|
||||
List<String> jsonPath = jsonPath(jsonProp);
|
||||
@NotNull Project project = element.getProject();
|
||||
@NotNull List<PsiField> psiFields = new ArrayList<>();
|
||||
@NotNull List<PsiField> tips = new ArrayList<>();
|
||||
@NotNull PsiClass[] psiClasses = PsiClassUtils.encClass(virtualFile, project);
|
||||
@NotNull List<String> jsonPath = jsonPath(jsonProp);
|
||||
put(project, psiFields, tips, psiClasses, jsonPath, jsonPath.size() - 1);
|
||||
|
||||
List<PsiReference> list = new ArrayList<>();
|
||||
for (PsiField psiField : psiFields) {
|
||||
@NotNull List<PsiReference> list = new ArrayList<>();
|
||||
for (@NotNull PsiField psiField : psiFields) {
|
||||
list.add(new JsonRef<>(element, psiField, tips));
|
||||
}
|
||||
return list.toArray(new PsiReference[0]);
|
||||
@@ -51,30 +53,30 @@ public class JsonJumpJava extends PsiReferenceContributor {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static List<String> jsonPath(JsonProperty jsonProp) {
|
||||
ArrayList<String> jsonPath = new ArrayList<>();
|
||||
private static List<String> jsonPath(@NotNull JsonProperty jsonProp) {
|
||||
@NotNull ArrayList<String> jsonPath = new ArrayList<>();
|
||||
do {
|
||||
jsonPath.add(jsonProp.getName());
|
||||
} while ((jsonProp = PsiTreeUtil.getParentOfType(jsonProp, JsonProperty.class)) != null);
|
||||
return jsonPath;
|
||||
}
|
||||
|
||||
private static void put(Project project, List<PsiField> psiFields, List<PsiField> tips,
|
||||
PsiClass[] psiClasses, List<String> jsonPath, int level) {
|
||||
private static void put(@NotNull Project project, @NotNull List<PsiField> psiFields, @NotNull List<PsiField> tips,
|
||||
@NotNull PsiClass[] psiClasses, @NotNull List<String> jsonPath, int level) {
|
||||
String name = jsonPath.get(level);
|
||||
for (PsiClass psiClass : psiClasses) {
|
||||
for (@NotNull PsiClass psiClass : psiClasses) {
|
||||
if (level == 1) {
|
||||
tips.addAll(Arrays.asList(psiClass.getAllFields()));
|
||||
}
|
||||
PsiField psiField = psiClass.findFieldByName(name, true);
|
||||
@Nullable PsiField psiField = psiClass.findFieldByName(name, true);
|
||||
if (psiField == null) {
|
||||
continue;
|
||||
}
|
||||
if (level == 0) {
|
||||
psiFields.add(psiField);
|
||||
} else {
|
||||
String classFullName = PsiClassUtils.toClassFullName(psiField);
|
||||
PsiClass[] classes = PsiClassUtils.fullNameToClass(classFullName, project);
|
||||
@NotNull String classFullName = PsiClassUtils.toClassFullName(psiField);
|
||||
@NotNull PsiClass[] classes = PsiClassUtils.fullNameToClass(classFullName, project);
|
||||
put(project, psiFields, tips, classes, jsonPath, level - 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ public class KotlinLangDoc extends BaseTagLangDoc<KDocSection> {
|
||||
if (resolve instanceof PsiPackageBase) {
|
||||
return null;
|
||||
}
|
||||
KDoc kDoc = PsiTreeUtil.getChildOfType(resolve, KDoc.class);
|
||||
@Nullable KDoc kDoc = PsiTreeUtil.getChildOfType(resolve, KDoc.class);
|
||||
if (kDoc == null) {
|
||||
return null;
|
||||
}
|
||||
@@ -48,18 +48,18 @@ public class KotlinLangDoc extends BaseTagLangDoc<KDocSection> {
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected <T extends SettingsInfo> String descDoc(@NotNull T lineInfo, @NotNull KDocSection kDocSection) {
|
||||
String content = kDocSection.getContent();
|
||||
protected <T extends SettingsInfo> String descDoc(@NotNull T lineInfo, @NotNull KDocSection kDocSection) {
|
||||
@NotNull String content = kDocSection.getContent();
|
||||
return DocFilter.cutDoc(content, lineInfo.appSettings, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected <T extends SettingsInfo> void appendTag(@NotNull T lineInfo, @NotNull StringBuilder tagStrBuilder,
|
||||
@NotNull KDocSection kDocSection, @NotNull String name) {
|
||||
List<KDocTag> tags = kDocSection.findTagsByName(name);
|
||||
for (KDocTag tag : tags) {
|
||||
String content = tag.getContent();
|
||||
String cutDoc = DocFilter.cutDoc(content, lineInfo.appSettings, false);
|
||||
@NotNull List<KDocTag> tags = kDocSection.findTagsByName(name);
|
||||
for (@NotNull KDocTag tag : tags) {
|
||||
@NotNull String content = tag.getContent();
|
||||
@NotNull String cutDoc = DocFilter.cutDoc(content, lineInfo.appSettings, false);
|
||||
tagStrBuilder.append(cutDoc);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,8 @@ public class OwnerToPsiDocUtils {
|
||||
|
||||
private OwnerToPsiDocUtils() {}
|
||||
|
||||
public static PsiDocComment srcOrByteCodeDoc(PsiDocCommentOwner psiDocCommentOwner) {
|
||||
@Nullable
|
||||
public static PsiDocComment srcOrByteCodeDoc(@NotNull PsiDocCommentOwner psiDocCommentOwner) {
|
||||
PsiElement navElement = psiDocCommentOwner.getNavigationElement();
|
||||
if (navElement instanceof PsiDocCommentOwner) {
|
||||
psiDocCommentOwner = (PsiDocCommentOwner) navElement;
|
||||
@@ -27,7 +28,7 @@ public class OwnerToPsiDocUtils {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static PsiDocComment supperMethodDoc(PsiMethod psiMethod) {
|
||||
public static PsiDocComment supperMethodDoc(@NotNull PsiMethod psiMethod) {
|
||||
return PsiMethodToPsiDoc.supperMethodDoc(psiMethod);
|
||||
}
|
||||
|
||||
@@ -36,14 +37,14 @@ public class OwnerToPsiDocUtils {
|
||||
if (psiPackage == null) {
|
||||
return null;
|
||||
}
|
||||
String name = psiPackage.getName();
|
||||
@Nullable String name = psiPackage.getName();
|
||||
if (name == null || name.length() == 0) {
|
||||
return null;
|
||||
}
|
||||
PsiDirectory[] psiDirectories = psiPackage.getDirectories();
|
||||
for (PsiDirectory psiDirectory : psiDirectories) {
|
||||
PsiFile file = psiDirectory.findFile(PsiPackage.PACKAGE_INFO_FILE);
|
||||
PsiDocComment psiDocComment = PackageFileToPsiDoc.fromPackageInfoFile(file);
|
||||
@NotNull PsiDirectory[] psiDirectories = psiPackage.getDirectories();
|
||||
for (@NotNull PsiDirectory psiDirectory : psiDirectories) {
|
||||
@Nullable PsiFile file = psiDirectory.findFile(PsiPackage.PACKAGE_INFO_FILE);
|
||||
@Nullable PsiDocComment psiDocComment = PackageFileToPsiDoc.fromPackageInfoFile(file);
|
||||
if (psiDocComment != null) {
|
||||
return psiDocComment;
|
||||
}
|
||||
@@ -55,14 +56,14 @@ public class OwnerToPsiDocUtils {
|
||||
public static PsiDocComment fileDoc(PsiFile psiFile) {
|
||||
if (!(psiFile instanceof PsiClassOwner)) {
|
||||
// for SPI
|
||||
PsiClass[] psiClasses = PsiClassUtils.nameToClass(psiFile.getName(), psiFile.getProject());
|
||||
@NotNull PsiClass[] psiClasses = PsiClassUtils.nameToClass(psiFile.getName(), psiFile.getProject());
|
||||
// for "xxx ClassName.xxx"
|
||||
if (psiClasses.length == 0) {
|
||||
VirtualFile virtualFile = psiFile.getVirtualFile();
|
||||
psiClasses = PsiClassUtils.encClass(virtualFile, psiFile.getProject());
|
||||
}
|
||||
for (PsiClass psiClass : psiClasses) {
|
||||
PsiDocComment docComment = srcOrByteCodeDoc(psiClass);
|
||||
for (@NotNull PsiClass psiClass : psiClasses) {
|
||||
@Nullable PsiDocComment docComment = srcOrByteCodeDoc(psiClass);
|
||||
if (docComment != null) {
|
||||
// Inaccurate when there are classes with the same name
|
||||
return docComment;
|
||||
@@ -73,8 +74,8 @@ public class OwnerToPsiDocUtils {
|
||||
if (PsiPackage.PACKAGE_INFO_FILE.equals(psiFile.getName())) {
|
||||
return PackageFileToPsiDoc.fromPackageInfoFile(psiFile);
|
||||
}
|
||||
PsiClassOwner psiClassOwner = (PsiClassOwner) psiFile;
|
||||
PsiClass[] classes = psiClassOwner.getClasses();
|
||||
@NotNull PsiClassOwner psiClassOwner = (PsiClassOwner) psiFile;
|
||||
@NotNull PsiClass[] classes = psiClassOwner.getClasses();
|
||||
if (classes.length == 0) {
|
||||
return null;
|
||||
}
|
||||
@@ -83,8 +84,8 @@ public class OwnerToPsiDocUtils {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static PsiDocComment dirDoc(PsiDirectory psiDirectory) {
|
||||
PsiPackage psiPackage = JavaDirectoryService.getInstance().getPackage(psiDirectory);
|
||||
public static PsiDocComment dirDoc(@NotNull PsiDirectory psiDirectory) {
|
||||
@Nullable PsiPackage psiPackage = JavaDirectoryService.getInstance().getPackage(psiDirectory);
|
||||
return packageDoc(psiPackage);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ class PackageFileToPsiDoc {
|
||||
private PackageFileToPsiDoc() {}
|
||||
|
||||
@Nullable
|
||||
static PsiDocComment fromPackageInfoFile(PsiFile packageInfoFile) {
|
||||
static PsiDocComment fromPackageInfoFile(@Nullable PsiFile packageInfoFile) {
|
||||
if (packageInfoFile == null) {
|
||||
return null;
|
||||
}
|
||||
@@ -21,15 +21,16 @@ class PackageFileToPsiDoc {
|
||||
if (astNode == null) {
|
||||
return null;
|
||||
}
|
||||
ASTNode docCommentNode = findRelevantCommentNode(astNode);
|
||||
@Nullable ASTNode docCommentNode = findRelevantCommentNode(astNode);
|
||||
if (docCommentNode == null) {
|
||||
return null;
|
||||
}
|
||||
return (PsiDocComment) docCommentNode;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static ASTNode findRelevantCommentNode(@NotNull ASTNode fileNode) {
|
||||
ASTNode node = fileNode.findChildByType(JavaElementType.PACKAGE_STATEMENT);
|
||||
@Nullable ASTNode node = fileNode.findChildByType(JavaElementType.PACKAGE_STATEMENT);
|
||||
if (node == null) node = fileNode.getLastChildNode();
|
||||
while (node != null && node.getElementType() != JavaDocElementType.DOC_COMMENT) {
|
||||
node = node.getTreePrev();
|
||||
|
||||
@@ -21,8 +21,8 @@ public class PsiClassUtils {
|
||||
|
||||
@NotNull
|
||||
public static PsiClass[] encClass(@NotNull VirtualFile virtualFile, @NotNull Project project) {
|
||||
String fileName = virtualFile.getNameWithoutExtension();
|
||||
Matcher matcher = JSON_PATTERN.matcher(fileName);
|
||||
@NotNull String fileName = virtualFile.getNameWithoutExtension();
|
||||
@NotNull Matcher matcher = JSON_PATTERN.matcher(fileName);
|
||||
if (!matcher.find()) {
|
||||
return new PsiClass[0];
|
||||
}
|
||||
@@ -58,10 +58,10 @@ public class PsiClassUtils {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static String toClassFullName(PsiField psiField) {
|
||||
public static String toClassFullName(@NotNull PsiField psiField) {
|
||||
// Array
|
||||
// use replace simpler than getDeepComponentType()
|
||||
String typeName = psiField.getType().getCanonicalText().replace("[]", "");
|
||||
@NotNull String typeName = psiField.getType().getCanonicalText().replace("[]", "");
|
||||
// List
|
||||
// use substring() because clsFieldImpl.getInnermostComponentReferenceElement() == null
|
||||
int index = typeName.indexOf("<");
|
||||
|
||||
@@ -20,19 +20,19 @@ class PsiMethodToPsiDoc {
|
||||
psiMethod = (PsiMethod) navElement;
|
||||
}
|
||||
|
||||
PsiDocComment docComment = psiMethod.getDocComment();
|
||||
@Nullable PsiDocComment docComment = psiMethod.getDocComment();
|
||||
if (docComment != null) {
|
||||
return docComment;
|
||||
}
|
||||
|
||||
// supper
|
||||
PsiDocComment superDoc = supperMethodDoc(psiMethod);
|
||||
@Nullable PsiDocComment superDoc = supperMethodDoc(psiMethod);
|
||||
if (superDoc != null) {
|
||||
return superDoc;
|
||||
}
|
||||
|
||||
|
||||
PsiClass clazz = psiMethod.getContainingClass();
|
||||
@Nullable PsiClass clazz = psiMethod.getContainingClass();
|
||||
if (clazz == null) {
|
||||
return null;
|
||||
}
|
||||
@@ -47,10 +47,10 @@ class PsiMethodToPsiDoc {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
static PsiDocComment supperMethodDoc(PsiMethod psiMethod) {
|
||||
PsiMethod[] superMethods = psiMethod.findSuperMethods();
|
||||
for (PsiMethod superMethod : superMethods) {
|
||||
PsiDocComment superDoc = OwnerToPsiDocUtils.methodDoc(superMethod);
|
||||
static PsiDocComment supperMethodDoc(@NotNull PsiMethod psiMethod) {
|
||||
@NotNull PsiMethod[] superMethods = psiMethod.findSuperMethods();
|
||||
for (@NotNull PsiMethod superMethod : superMethods) {
|
||||
@Nullable PsiDocComment superDoc = OwnerToPsiDocUtils.methodDoc(superMethod);
|
||||
if (superDoc != null) {
|
||||
return superDoc;
|
||||
}
|
||||
@@ -59,8 +59,8 @@ class PsiMethodToPsiDoc {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static PsiDocComment propMethodDoc(PsiMethod psiMethod, PsiClass psiClass) {
|
||||
String name = psiMethod.getName();
|
||||
private static PsiDocComment propMethodDoc(@NotNull PsiMethod psiMethod, @NotNull PsiClass psiClass) {
|
||||
@NotNull String name = psiMethod.getName();
|
||||
if (name.length() > 3 && (name.startsWith("get") || name.startsWith("set"))) {
|
||||
name = name.substring(3);
|
||||
} else if (name.length() > 2 && name.startsWith("is")) {
|
||||
@@ -68,10 +68,10 @@ class PsiMethodToPsiDoc {
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
char[] chars = name.toCharArray();
|
||||
@NotNull char[] chars = name.toCharArray();
|
||||
chars[0] += 32;
|
||||
name = String.valueOf(chars);
|
||||
PsiField fieldByName = psiClass.findFieldByName(name, false);
|
||||
@Nullable PsiField fieldByName = psiClass.findFieldByName(name, false);
|
||||
if (fieldByName == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -14,11 +14,11 @@ public class NewCallRefToPsiDoc {
|
||||
private NewCallRefToPsiDoc() {}
|
||||
|
||||
@Nullable
|
||||
public static PsiDocComment javaCodeDoc(PsiJavaCodeReferenceElement ref) {
|
||||
public static PsiDocComment javaCodeDoc(@Nullable PsiJavaCodeReferenceElement ref) {
|
||||
if (ref == null) {
|
||||
return null;
|
||||
}
|
||||
PsiElement resolve = null;
|
||||
@Nullable PsiElement resolve = null;
|
||||
try {
|
||||
resolve = ref.resolve();
|
||||
} catch (Throwable ignore) {
|
||||
|
||||
@@ -6,6 +6,7 @@ import com.intellij.psi.javadoc.PsiDocComment;
|
||||
import io.github.linwancen.plugin.show.java.doc.OwnerToPsiDocUtils;
|
||||
import io.github.linwancen.plugin.show.settings.AppSettingsState;
|
||||
import io.github.linwancen.plugin.show.settings.ProjectSettingsState;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
@@ -19,12 +20,12 @@ public class OwnerToPsiDocSkip {
|
||||
if (docOwner == null) {
|
||||
return null;
|
||||
}
|
||||
AppSettingsState appSettings = AppSettingsState.getInstance();
|
||||
ProjectSettingsState projectSettings = ProjectSettingsState.getInstance(docOwner.getProject());
|
||||
@NotNull AppSettingsState appSettings = AppSettingsState.getInstance();
|
||||
@NotNull ProjectSettingsState projectSettings = ProjectSettingsState.getInstance(docOwner.getProject());
|
||||
if (SkipUtils.skipSign(docOwner, appSettings, projectSettings)) {
|
||||
return null;
|
||||
}
|
||||
PsiDocComment docComment = docOwner instanceof PsiMethod
|
||||
@Nullable PsiDocComment docComment = docOwner instanceof PsiMethod
|
||||
? OwnerToPsiDocUtils.methodDoc(((PsiMethod) docOwner))
|
||||
: OwnerToPsiDocUtils.srcOrByteCodeDoc(docOwner);
|
||||
return SkipUtils.skipDoc(docComment, appSettings, projectSettings);
|
||||
|
||||
@@ -8,39 +8,41 @@ import io.github.linwancen.plugin.show.lang.base.DocSkip;
|
||||
import io.github.linwancen.plugin.show.settings.AppSettingsState;
|
||||
import io.github.linwancen.plugin.show.settings.ProjectSettingsState;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
class SkipUtils {
|
||||
|
||||
private SkipUtils() {}
|
||||
|
||||
static boolean skipSign(PsiElement psiElement, AppSettingsState appSettings, ProjectSettingsState projectSettings) {
|
||||
String text = psiName(psiElement, appSettings);
|
||||
static boolean skipSign(PsiElement psiElement, @NotNull AppSettingsState appSettings,
|
||||
@NotNull ProjectSettingsState projectSettings) {
|
||||
@Nullable String text = psiName(psiElement, appSettings);
|
||||
if (text == null) {
|
||||
return true;
|
||||
}
|
||||
return DocSkip.skipSign(appSettings, projectSettings, text);
|
||||
}
|
||||
|
||||
private static @Nullable String psiName(@Nullable PsiElement psiElement, AppSettingsState appSettings) {
|
||||
private static @Nullable String psiName(@Nullable PsiElement psiElement, @NotNull AppSettingsState appSettings) {
|
||||
if (psiElement instanceof PsiClass) {
|
||||
PsiClass psiClass = (PsiClass) psiElement;
|
||||
@NotNull PsiClass psiClass = (PsiClass) psiElement;
|
||||
if (appSettings.skipAnnotation && psiClass.isAnnotationType()) {
|
||||
return null;
|
||||
}
|
||||
return psiClass.getQualifiedName();
|
||||
} else if (psiElement instanceof PsiMember) {
|
||||
PsiMember psiMember = (PsiMember) psiElement;
|
||||
StringBuilder sb = new StringBuilder();
|
||||
PsiClass psiClass = psiMember.getContainingClass();
|
||||
@NotNull PsiMember psiMember = (PsiMember) psiElement;
|
||||
@NotNull StringBuilder sb = new StringBuilder();
|
||||
@Nullable PsiClass psiClass = psiMember.getContainingClass();
|
||||
if (psiClass != null) {
|
||||
String className = psiClass.getQualifiedName();
|
||||
@Nullable String className = psiClass.getQualifiedName();
|
||||
if (className != null) {
|
||||
sb.append(className);
|
||||
}
|
||||
}
|
||||
sb.append("#");
|
||||
String name = psiMember.getName();
|
||||
@Nullable String name = psiMember.getName();
|
||||
if (name != null) {
|
||||
sb.append(name);
|
||||
}
|
||||
@@ -49,7 +51,8 @@ class SkipUtils {
|
||||
return null;
|
||||
}
|
||||
|
||||
static PsiDocComment skipDoc(PsiDocComment doc, AppSettingsState appSettings, ProjectSettingsState projectSettings) {
|
||||
static PsiDocComment skipDoc(@Nullable PsiDocComment doc, @NotNull AppSettingsState appSettings,
|
||||
@NotNull ProjectSettingsState projectSettings) {
|
||||
if (doc == null) {
|
||||
return null;
|
||||
}
|
||||
@@ -61,9 +64,9 @@ class SkipUtils {
|
||||
return skip ? null : doc;
|
||||
}
|
||||
|
||||
private static boolean isBlank(PsiDocComment doc) {
|
||||
PsiElement[] elements = doc.getDescriptionElements();
|
||||
for (PsiElement element : elements) {
|
||||
private static boolean isBlank(@NotNull PsiDocComment doc) {
|
||||
@NotNull PsiElement[] elements = doc.getDescriptionElements();
|
||||
for (@NotNull PsiElement element : elements) {
|
||||
String text = element.getText();
|
||||
if (StringUtils.isNotBlank(text)) {
|
||||
return false;
|
||||
|
||||
@@ -10,6 +10,7 @@ import com.intellij.psi.PsiDocumentManager;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.regex.Pattern;
|
||||
@@ -27,16 +28,17 @@ public class CopyReferenceSimple extends CopyReferenceAction {
|
||||
|
||||
private static final Pattern QUALIFIED_PATTERN = Pattern.compile("[\\w.]+\\.");
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
protected String getQualifiedName(Editor editor, List<PsiElement> elements) {
|
||||
protected String getQualifiedName(@NotNull Editor editor, List<PsiElement> elements) {
|
||||
String qualifiedName = super.getQualifiedName(editor, elements);
|
||||
if (qualifiedName == null) {
|
||||
Document document = editor.getDocument();
|
||||
Project project = editor.getProject();
|
||||
@NotNull Document document = editor.getDocument();
|
||||
@Nullable Project project = editor.getProject();
|
||||
if (project == null) {
|
||||
return null;
|
||||
}
|
||||
PsiFile file = PsiDocumentManager.getInstance(project).getCachedPsiFile(document);
|
||||
@Nullable PsiFile file = PsiDocumentManager.getInstance(project).getCachedPsiFile(document);
|
||||
if (file != null) {
|
||||
// getFileFqn(file) => file.getName()
|
||||
return file.getName() + ":" + (editor.getCaretModel().getLogicalPosition().line + 1);
|
||||
|
||||
@@ -24,7 +24,7 @@ public class LineEnd extends EditorLinePainter {
|
||||
@Override
|
||||
public @Nullable Collection<LineExtensionInfo> getLineExtensions(@NotNull Project project,
|
||||
@NotNull VirtualFile file, int lineNumber) {
|
||||
AppSettingsState settings = AppSettingsState.getInstance();
|
||||
@NotNull AppSettingsState settings = AppSettingsState.getInstance();
|
||||
if (!settings.showLineEndComment) {
|
||||
return null;
|
||||
}
|
||||
@@ -34,30 +34,30 @@ public class LineEnd extends EditorLinePainter {
|
||||
if (!file.exists()) {
|
||||
return null;
|
||||
}
|
||||
LineInfo lineInfo = LineInfo.of(file, project, lineNumber);
|
||||
String doc = lineDocSkipHave(lineInfo);
|
||||
@Nullable LineInfo lineInfo = LineInfo.of(file, project, lineNumber);
|
||||
@Nullable String doc = lineDocSkipHave(lineInfo);
|
||||
if (doc == null) {
|
||||
return null;
|
||||
}
|
||||
TextAttributes textAttr = file.getFileType().equals(JsonFileType.INSTANCE)
|
||||
@NotNull TextAttributes textAttr = file.getFileType().equals(JsonFileType.INSTANCE)
|
||||
|| file.getFileType().equals(Json5FileType.INSTANCE)
|
||||
? settings.lineEndJsonTextAttr
|
||||
: settings.lineEndTextAttr;
|
||||
LineExtensionInfo info = new LineExtensionInfo(settings.lineEndPrefix + doc, textAttr);
|
||||
@NotNull LineExtensionInfo info = new LineExtensionInfo(settings.lineEndPrefix + doc, textAttr);
|
||||
return Collections.singletonList(info);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static String textWithDoc(@NotNull FileInfo fileInfo, int startLine, int endLine) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
@NotNull StringBuilder sb = new StringBuilder();
|
||||
for (int i = startLine; i <= endLine; i++) {
|
||||
LineInfo lineInfo = LineInfo.of(fileInfo, i);
|
||||
@Nullable LineInfo lineInfo = LineInfo.of(fileInfo, i);
|
||||
if (lineInfo == null) {
|
||||
sb.append("\n");
|
||||
continue;
|
||||
}
|
||||
sb.append(lineInfo.text);
|
||||
String doc = lineDocSkipHave(lineInfo);
|
||||
@Nullable String doc = lineDocSkipHave(lineInfo);
|
||||
if (doc != null) {
|
||||
sb.append(lineInfo.appSettings.lineEndPrefix).append(doc);
|
||||
}
|
||||
@@ -70,11 +70,11 @@ public class LineEnd extends EditorLinePainter {
|
||||
}
|
||||
|
||||
private static @Nullable String lineDocSkipHave(@Nullable LineInfo lineInfo) {
|
||||
String doc = lineDoc(lineInfo);
|
||||
@Nullable String doc = lineDoc(lineInfo);
|
||||
if (doc == null) {
|
||||
return null;
|
||||
}
|
||||
String trimDoc = doc.trim();
|
||||
@NotNull String trimDoc = doc.trim();
|
||||
if (lineInfo.text.trim().endsWith(trimDoc)) {
|
||||
return null;
|
||||
}
|
||||
@@ -86,7 +86,7 @@ public class LineEnd extends EditorLinePainter {
|
||||
return null;
|
||||
}
|
||||
// override some text
|
||||
String doc = LineExt.doc(lineInfo);
|
||||
@Nullable String doc = LineExt.doc(lineInfo);
|
||||
if (doc != null) {
|
||||
return doc;
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.vfs.VirtualFileVisitor;
|
||||
import io.github.linwancen.plugin.show.bean.FileInfo;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* on ProjectViewPopupMenu
|
||||
@@ -21,22 +22,22 @@ public class LineEndAdd extends DumbAwareAction {
|
||||
|
||||
@Override
|
||||
public void actionPerformed(@NotNull AnActionEvent event) {
|
||||
Project project = event.getProject();
|
||||
@Nullable Project project = event.getProject();
|
||||
if (project == null) {
|
||||
return;
|
||||
}
|
||||
VirtualFile[] files = event.getData(CommonDataKeys.VIRTUAL_FILE_ARRAY);
|
||||
@Nullable VirtualFile[] files = event.getData(CommonDataKeys.VIRTUAL_FILE_ARRAY);
|
||||
if (files == null) {
|
||||
return;
|
||||
}
|
||||
ListPopup confirmation = JBPopupFactory.getInstance().createConfirmation(
|
||||
@NotNull ListPopup confirmation = JBPopupFactory.getInstance().createConfirmation(
|
||||
"Add Line Comment?", "Add and replace files!", "Don't add.",
|
||||
() -> ApplicationManager.getApplication().runReadAction(() -> addDocAll(project, files)), 2);
|
||||
confirmation.showInFocusCenter();
|
||||
}
|
||||
|
||||
private void addDocAll(@NotNull Project project, @NotNull VirtualFile[] files) {
|
||||
for (VirtualFile file : files) {
|
||||
for (@NotNull VirtualFile file : files) {
|
||||
VfsUtilCore.visitChildrenRecursively(file, new VirtualFileVisitor<Void>() {
|
||||
@Override
|
||||
public boolean visitFile(@NotNull VirtualFile file) {
|
||||
@@ -50,13 +51,13 @@ public class LineEndAdd extends DumbAwareAction {
|
||||
}
|
||||
|
||||
private void addDoc(@NotNull Project project, @NotNull VirtualFile file) {
|
||||
FileInfo fileInfo = FileInfo.of(file, project);
|
||||
@Nullable FileInfo fileInfo = FileInfo.of(file, project);
|
||||
if (fileInfo == null) {
|
||||
return;
|
||||
}
|
||||
int startLine = 0;
|
||||
int endLine = fileInfo.document.getLineCount() - 1;
|
||||
String textWithDoc = LineEnd.textWithDoc(fileInfo, startLine, endLine);
|
||||
@NotNull String textWithDoc = LineEnd.textWithDoc(fileInfo, startLine, endLine);
|
||||
WriteCommandAction.runWriteCommandAction(project, () ->
|
||||
fileInfo.document.replaceString(0, fileInfo.document.getTextLength() - 1, textWithDoc)
|
||||
);
|
||||
|
||||
@@ -9,6 +9,7 @@ import com.intellij.openapi.ide.CopyPasteManager;
|
||||
import com.intellij.openapi.project.DumbAwareAction;
|
||||
import io.github.linwancen.plugin.show.bean.FileInfo;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.awt.datatransfer.StringSelection;
|
||||
|
||||
@@ -23,16 +24,16 @@ public class LineEndCopy extends DumbAwareAction {
|
||||
}
|
||||
|
||||
private void copyWithDoc(@NotNull AnActionEvent event) {
|
||||
FileInfo fileInfo = FileInfo.of(event);
|
||||
@Nullable FileInfo fileInfo = FileInfo.of(event);
|
||||
if (fileInfo == null) {
|
||||
return;
|
||||
}
|
||||
int startLine = 0;
|
||||
int endLine = fileInfo.document.getLineCount() - 1;
|
||||
// if select
|
||||
Editor editor = event.getData(CommonDataKeys.EDITOR);
|
||||
@Nullable Editor editor = event.getData(CommonDataKeys.EDITOR);
|
||||
if (editor != null) {
|
||||
Caret primaryCaret = editor.getCaretModel().getPrimaryCaret();
|
||||
@NotNull Caret primaryCaret = editor.getCaretModel().getPrimaryCaret();
|
||||
int start = primaryCaret.getSelectionStart();
|
||||
int end = primaryCaret.getSelectionEnd();
|
||||
try {
|
||||
@@ -42,8 +43,8 @@ public class LineEndCopy extends DumbAwareAction {
|
||||
return;
|
||||
}
|
||||
}
|
||||
String textWithDoc = LineEnd.textWithDoc(fileInfo, startLine, endLine);
|
||||
StringSelection content = new StringSelection(textWithDoc);
|
||||
@NotNull String textWithDoc = LineEnd.textWithDoc(fileInfo, startLine, endLine);
|
||||
@NotNull StringSelection content = new StringSelection(textWithDoc);
|
||||
CopyPasteManager.getInstance().setContents(content);
|
||||
}
|
||||
}
|
||||
@@ -25,11 +25,11 @@ import java.util.List;
|
||||
public class Tree implements ProjectViewNodeDecorator {
|
||||
|
||||
@Override
|
||||
public void decorate(ProjectViewNode node, PresentationData data) {
|
||||
public void decorate(@NotNull ProjectViewNode node, @NotNull PresentationData data) {
|
||||
if (!AppSettingsState.getInstance().showTreeComment) {
|
||||
return;
|
||||
}
|
||||
Project project = node.getProject();
|
||||
@Nullable Project project = node.getProject();
|
||||
if (project == null) {
|
||||
return;
|
||||
}
|
||||
@@ -37,11 +37,11 @@ public class Tree implements ProjectViewNodeDecorator {
|
||||
return;
|
||||
}
|
||||
ApplicationManager.getApplication().runReadAction(() -> {
|
||||
String doc = treeDoc(node, project);
|
||||
@Nullable String doc = treeDoc(node, project);
|
||||
if (doc == null) {
|
||||
return;
|
||||
}
|
||||
List<ColoredFragment> coloredText = data.getColoredText();
|
||||
@NotNull List<ColoredFragment> coloredText = data.getColoredText();
|
||||
if (coloredText.isEmpty()) {
|
||||
data.addText(data.getPresentableText(), SimpleTextAttributes.REGULAR_ATTRIBUTES);
|
||||
}
|
||||
@@ -50,23 +50,23 @@ public class Tree implements ProjectViewNodeDecorator {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private String treeDoc(ProjectViewNode<?> node, @NotNull Project project) {
|
||||
String doc = TreeExt.doc(node);
|
||||
private String treeDoc(@NotNull ProjectViewNode<?> node, @NotNull Project project) {
|
||||
@Nullable String doc = TreeExt.doc(node);
|
||||
if (doc != null) {
|
||||
return doc;
|
||||
}
|
||||
SettingsInfo settingsInfo = SettingsInfo.of(project, FuncEnum.TREE);
|
||||
@NotNull SettingsInfo settingsInfo = SettingsInfo.of(project, FuncEnum.TREE);
|
||||
Object value = node.getValue();
|
||||
if (value instanceof PsiElement) {
|
||||
PsiElement psiElement = (PsiElement) value;
|
||||
String docPrint = BaseLangDoc.resolveDoc(settingsInfo, psiElement);
|
||||
@NotNull PsiElement psiElement = (PsiElement) value;
|
||||
@Nullable String docPrint = BaseLangDoc.resolveDoc(settingsInfo, psiElement);
|
||||
if (docPrint != null) {
|
||||
return docPrint;
|
||||
}
|
||||
}
|
||||
Collection<BaseLangDoc> langDocs = BaseLangDoc.LANG_DOC_MAP.values();
|
||||
for (BaseLangDoc langDoc : langDocs) {
|
||||
String s = langDoc.treeDoc(settingsInfo, node, project);
|
||||
@NotNull Collection<BaseLangDoc> langDocs = BaseLangDoc.LANG_DOC_MAP.values();
|
||||
for (@NotNull BaseLangDoc langDoc : langDocs) {
|
||||
@Nullable String s = langDoc.treeDoc(settingsInfo, node, project);
|
||||
if (s != null) {
|
||||
return s;
|
||||
}
|
||||
|
||||
@@ -27,30 +27,30 @@ public class FileInfo extends SettingsInfo {
|
||||
this.document = document;
|
||||
}
|
||||
|
||||
public static @Nullable FileInfo of(@NotNull VirtualFile file, @NotNull Project project){
|
||||
Document document = FileDocumentManager.getInstance().getDocument(file);
|
||||
public static @Nullable FileInfo of(@NotNull VirtualFile file, @NotNull Project project) {
|
||||
@Nullable Document document = FileDocumentManager.getInstance().getDocument(file);
|
||||
if (document == null) {
|
||||
return null;
|
||||
}
|
||||
FileViewProvider viewProvider = PsiManager.getInstance(project).findViewProvider(file);
|
||||
@Nullable FileViewProvider viewProvider = PsiManager.getInstance(project).findViewProvider(file);
|
||||
if (viewProvider == null) {
|
||||
return null;
|
||||
}
|
||||
return new FileInfo(file, document, project, viewProvider, FuncEnum.LINE);
|
||||
}
|
||||
|
||||
public static @Nullable FileInfo of(@NotNull AnActionEvent event){
|
||||
PsiFile psiFile = event.getData(CommonDataKeys.PSI_FILE);
|
||||
public static @Nullable FileInfo of(@NotNull AnActionEvent event) {
|
||||
@Nullable PsiFile psiFile = event.getData(CommonDataKeys.PSI_FILE);
|
||||
if (psiFile == null) {
|
||||
return null;
|
||||
}
|
||||
FileViewProvider viewProvider = psiFile.getViewProvider();
|
||||
Document document = viewProvider.getDocument();
|
||||
@NotNull FileViewProvider viewProvider = psiFile.getViewProvider();
|
||||
@Nullable Document document = viewProvider.getDocument();
|
||||
if (document == null) {
|
||||
return null;
|
||||
}
|
||||
VirtualFile file = viewProvider.getVirtualFile();
|
||||
Project project = psiFile.getProject();
|
||||
@NotNull VirtualFile file = viewProvider.getVirtualFile();
|
||||
@NotNull Project project = psiFile.getProject();
|
||||
return new FileInfo(file, document, project, viewProvider, FuncEnum.LINE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
package io.github.linwancen.plugin.show.bean;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
|
||||
public enum FuncEnum {
|
||||
/** tree: project view tree */
|
||||
/** tree: project view tree */
|
||||
TREE("tree", "project view tree"),
|
||||
/** line: code line end */
|
||||
LINE("line", "code line end"),
|
||||
@@ -17,16 +19,18 @@ public enum FuncEnum {
|
||||
this.desc = desc;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String toString() {
|
||||
return code + '-' + desc;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static final LinkedHashMap<String, FuncEnum> map;
|
||||
|
||||
static {
|
||||
map = new LinkedHashMap<>();
|
||||
for (FuncEnum value : values()) {
|
||||
for (@NotNull FuncEnum value : values()) {
|
||||
map.put(value.code, value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ public class LineInfo extends FileInfo {
|
||||
}
|
||||
|
||||
public static @Nullable LineInfo of(@NotNull VirtualFile file, @NotNull Project project, int lineNumber) {
|
||||
FileInfo fileInfo = of(file, project);
|
||||
@Nullable FileInfo fileInfo = of(file, project);
|
||||
if (fileInfo == null) {
|
||||
return null;
|
||||
}
|
||||
@@ -40,7 +40,7 @@ public class LineInfo extends FileInfo {
|
||||
if (startOffset == endOffset) {
|
||||
return null;
|
||||
}
|
||||
String text = fileInfo.document.getText(new TextRange(startOffset, endOffset));
|
||||
@NotNull String text = fileInfo.document.getText(new TextRange(startOffset, endOffset));
|
||||
return new LineInfo(fileInfo, text, lineNumber, startOffset, endOffset);
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
|
||||
@@ -16,11 +16,12 @@ public class SettingsInfo {
|
||||
this.projectSettings = ProjectSettingsState.getInstance(project);
|
||||
}
|
||||
|
||||
public static @NotNull SettingsInfo of(@NotNull Project project, FuncEnum funcEnum) {
|
||||
public static @NotNull SettingsInfo of(@NotNull Project project, @NotNull FuncEnum funcEnum) {
|
||||
return new SettingsInfo(project, funcEnum);
|
||||
}
|
||||
|
||||
/** treeTags/lineTags */
|
||||
@NotNull
|
||||
public String[] tagNames() {
|
||||
return funcEnum == FuncEnum.TREE
|
||||
? appSettings.treeTags
|
||||
|
||||
@@ -13,7 +13,7 @@ class GetFromDocMap {
|
||||
|
||||
@Nullable
|
||||
static String get(@NotNull Map<String, Map<String, List<String>>> docMap, @NotNull String... words) {
|
||||
List<String> keywordDoc = list(docMap, words);
|
||||
@NotNull List<String> keywordDoc = list(docMap, words);
|
||||
if (keywordDoc.size() >= 2) {
|
||||
return keywordDoc.get(1);
|
||||
}
|
||||
@@ -22,7 +22,7 @@ class GetFromDocMap {
|
||||
|
||||
@NotNull
|
||||
private static List<String> list(@NotNull Map<String, Map<String, List<String>>> docMap, @NotNull String... words) {
|
||||
for (Map.Entry<String, Map<String, List<String>>> entry : docMap.entrySet()) {
|
||||
for (@NotNull Map.Entry<String, Map<String, List<String>>> entry : docMap.entrySet()) {
|
||||
Map<String, List<String>> map = entry.getValue();
|
||||
for (String word : words) {
|
||||
List<String> wordDoc = map.get(word);
|
||||
|
||||
@@ -16,8 +16,8 @@ public class LineExt {
|
||||
|
||||
public static @Nullable String doc(@NotNull LineInfo lineInfo) {
|
||||
int i = lineInfo.text.indexOf(lineInfo.appSettings.lineEndPrefix);
|
||||
String code = i <= 0 ? lineInfo.text : lineInfo.text.substring(0, i);
|
||||
String extDoc = LineExt.extDoc(lineInfo, code);
|
||||
@NotNull String code = i <= 0 ? lineInfo.text : lineInfo.text.substring(0, i);
|
||||
@Nullable String extDoc = LineExt.extDoc(lineInfo, code);
|
||||
if (extDoc == null) {
|
||||
return null;
|
||||
}
|
||||
@@ -28,20 +28,21 @@ public class LineExt {
|
||||
return extDoc;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static String extDoc(@NotNull LineInfo lineInfo, @NotNull String code) {
|
||||
String path = lineInfo.file.getPath();
|
||||
String name = lineInfo.file.getName();
|
||||
String ext = lineInfo.file.getExtension();
|
||||
Map<String, Map<String, List<String>>> keyMap = ConfCache.keyMap(path, name, ext);
|
||||
@NotNull String path = lineInfo.file.getPath();
|
||||
@NotNull String name = lineInfo.file.getName();
|
||||
@Nullable String ext = lineInfo.file.getExtension();
|
||||
@NotNull Map<String, Map<String, List<String>>> keyMap = ConfCache.keyMap(path, name, ext);
|
||||
if (keyMap.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
Pattern pattern = ConfCache.pattern(lineInfo.project, keyMap, path);
|
||||
@Nullable Pattern pattern = ConfCache.pattern(lineInfo.project, keyMap, path);
|
||||
if (pattern == null || pattern.pattern().length() == 0) {
|
||||
return null;
|
||||
}
|
||||
Map<String, Map<String, List<String>>> docMap = ConfCache.docMap(path, name, ext);
|
||||
Map<String, Map<String, List<String>>> treeMap = ConfCache.treeMap(path, name, ext);
|
||||
@NotNull Map<String, Map<String, List<String>>> docMap = ConfCache.docMap(path, name, ext);
|
||||
@NotNull Map<String, Map<String, List<String>>> treeMap = ConfCache.treeMap(path, name, ext);
|
||||
if (docMap.isEmpty() && treeMap.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
@@ -49,7 +50,7 @@ public class LineExt {
|
||||
code = cblNotAndOr(code);
|
||||
}
|
||||
String[] words = pattern.split(code);
|
||||
Matcher matcher = pattern.matcher(code);
|
||||
@NotNull Matcher matcher = pattern.matcher(code);
|
||||
return extDoc(keyMap, matcher, docMap, words, treeMap);
|
||||
}
|
||||
|
||||
@@ -57,12 +58,12 @@ public class LineExt {
|
||||
private static final Pattern AND_OR_PATTERN = Pattern.compile("(AND|OR) ?'");
|
||||
|
||||
@NotNull
|
||||
private static String cblNotAndOr(String text) {
|
||||
private static String cblNotAndOr(@NotNull String text) {
|
||||
// maybe faster than regexp
|
||||
if (!text.contains("=")) {
|
||||
return text;
|
||||
}
|
||||
Matcher matcher = DICT_PATTERN.matcher(text);
|
||||
@NotNull Matcher matcher = DICT_PATTERN.matcher(text);
|
||||
if (!matcher.find()) {
|
||||
return text;
|
||||
}
|
||||
@@ -81,13 +82,13 @@ public class LineExt {
|
||||
@NotNull Map<String, Map<String, List<String>>> treeMap) {
|
||||
boolean haveDoc = false;
|
||||
boolean haveKey = false;
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (String s : words) {
|
||||
@NotNull StringBuilder sb = new StringBuilder();
|
||||
for (@NotNull String s : words) {
|
||||
haveDoc |= appendDoc(sb, s, docMap, treeMap);
|
||||
haveKey = appendKeyDoc(sb, matcher, keyMap);
|
||||
}
|
||||
while (haveKey) {
|
||||
haveKey = appendKeyDoc(sb, matcher, keyMap);
|
||||
haveKey = appendKeyDoc(sb, matcher, keyMap);
|
||||
}
|
||||
if (!haveDoc) {
|
||||
return null;
|
||||
@@ -102,12 +103,12 @@ public class LineExt {
|
||||
if (word.length() == 0) {
|
||||
return false;
|
||||
}
|
||||
String wordDoc = GetFromDocMap.get(docMap, word);
|
||||
@Nullable String wordDoc = GetFromDocMap.get(docMap, word);
|
||||
if (wordDoc != null) {
|
||||
sb.append(wordDoc);
|
||||
return true;
|
||||
}
|
||||
String treeDoc = GetFromDocMap.get(treeMap, word);
|
||||
@Nullable String treeDoc = GetFromDocMap.get(treeMap, word);
|
||||
if (treeDoc != null) {
|
||||
sb.append(treeDoc);
|
||||
return true;
|
||||
@@ -118,14 +119,14 @@ public class LineExt {
|
||||
}
|
||||
|
||||
private static boolean appendKeyDoc(@NotNull StringBuilder sb,
|
||||
@NotNull Matcher matcher,
|
||||
@NotNull Map<String, Map<String, List<String>>> keyMap) {
|
||||
@NotNull Matcher matcher,
|
||||
@NotNull Map<String, Map<String, List<String>>> keyMap) {
|
||||
if (!matcher.find()) {
|
||||
return false;
|
||||
}
|
||||
String keyword = matcher.group();
|
||||
// "" if no doc
|
||||
String keyDoc = GetFromDocMap.get(keyMap, keyword);
|
||||
@Nullable String keyDoc = GetFromDocMap.get(keyMap, keyword);
|
||||
if (keyDoc != null) {
|
||||
sb.append(" ").append(keyDoc);
|
||||
}
|
||||
|
||||
@@ -13,21 +13,23 @@ public class TreeExt {
|
||||
|
||||
private TreeExt() {}
|
||||
|
||||
public static @Nullable String doc(ProjectViewNode<?> node) {
|
||||
VirtualFile file = node.getVirtualFile();
|
||||
public static @Nullable String doc(@NotNull ProjectViewNode<?> node) {
|
||||
@Nullable VirtualFile file = node.getVirtualFile();
|
||||
if (file == null) {
|
||||
return null;
|
||||
}
|
||||
return TreeExt.extDoc(file);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static String extDoc(@NotNull VirtualFile file) {
|
||||
Map<String, Map<String, List<String>>> docMap = ConfCache.treeMap(file.getPath(), file.getName(), file.getPath());
|
||||
String[] words = {
|
||||
@NotNull Map<String, Map<String, List<String>>> docMap = ConfCache.treeMap(
|
||||
file.getPath(), file.getName(), file.getPath());
|
||||
@NotNull String[] words = {
|
||||
file.getName(),
|
||||
file.getNameWithoutExtension(),
|
||||
};
|
||||
String extDoc = GetFromDocMap.get(docMap, words);
|
||||
@Nullable String extDoc = GetFromDocMap.get(docMap, words);
|
||||
if (extDoc == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ public class ConfCache {
|
||||
TREE_CACHE.clear();
|
||||
}
|
||||
|
||||
static void remove(@NotNull VirtualFile file, String name) {
|
||||
static void remove(@NotNull VirtualFile file, @Nullable String name) {
|
||||
if (name != null) {
|
||||
int i = name.lastIndexOf('.');
|
||||
name = name.substring(0, i);
|
||||
@@ -93,7 +93,7 @@ public class ConfCache {
|
||||
}
|
||||
|
||||
static void copy(@NotNull VirtualFile file, @NotNull VirtualFile newFile) {
|
||||
String name = file.getNameWithoutExtension();
|
||||
@NotNull String name = file.getNameWithoutExtension();
|
||||
if (name.endsWith(KEY_MID_EXT)) {
|
||||
copyCache(file, newFile, KEY_CACHE);
|
||||
} else if (name.endsWith(DOC_MID_EXT)) {
|
||||
@@ -117,9 +117,9 @@ public class ConfCache {
|
||||
static void loadAll(@NotNull Project project) {
|
||||
DumbService.getInstance(project).runReadActionInSmartMode(() ->
|
||||
ApplicationManager.getApplication().runReadAction(() -> {
|
||||
Collection<VirtualFile> files = FilenameIndex.getAllFilesByExt(project, EXT);
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (VirtualFile file : files) {
|
||||
@NotNull Collection<VirtualFile> files = FilenameIndex.getAllFilesByExt(project, EXT);
|
||||
@NotNull StringBuilder sb = new StringBuilder();
|
||||
for (@NotNull VirtualFile file : files) {
|
||||
load(project, file);
|
||||
sb.append(file.getName()).append("\n");
|
||||
}
|
||||
@@ -139,16 +139,16 @@ public class ConfCache {
|
||||
if (!ConfCache.EXT.equals(file.getExtension())) {
|
||||
return;
|
||||
}
|
||||
Document document = FileDocumentManager.getInstance().getDocument(file);
|
||||
@Nullable Document document = FileDocumentManager.getInstance().getDocument(file);
|
||||
if (document == null) {
|
||||
return;
|
||||
}
|
||||
String text = document.getText();
|
||||
String name = file.getNameWithoutExtension();
|
||||
@NotNull String text = document.getText();
|
||||
@NotNull String name = file.getNameWithoutExtension();
|
||||
// this pattern would skip empty line
|
||||
String[] lines = LINE_PATTERN.split(text);
|
||||
if (name.endsWith(KEY_MID_EXT)) {
|
||||
String matchName = name.substring(0, name.length() - KEY_MID_EXT.length());
|
||||
@NotNull String matchName = name.substring(0, name.length() - KEY_MID_EXT.length());
|
||||
int i = matchName.lastIndexOf(".");
|
||||
if (i > 0) {
|
||||
EXT_IN_KEY_CACHE.add(matchName.substring(i + 1));
|
||||
|
||||
@@ -32,13 +32,13 @@ class ConfCacheGetUtils {
|
||||
static <T> TreeMap<String, T> filterPathNameExt(@NotNull String confMidExt,
|
||||
@NotNull Map<VirtualFile, T> cache,
|
||||
@NotNull String path, @NotNull String name, @Nullable String ext) {
|
||||
TreeMap<String, T> map = new TreeMap<>();
|
||||
@NotNull TreeMap<String, T> map = new TreeMap<>();
|
||||
int max = path.length();
|
||||
int length = String.valueOf(max).length();
|
||||
for (Map.Entry<VirtualFile, T> entry : cache.entrySet()) {
|
||||
for (@NotNull Map.Entry<VirtualFile, T> entry : cache.entrySet()) {
|
||||
VirtualFile confFile = entry.getKey();
|
||||
String confName = confFile.getNameWithoutExtension();
|
||||
String confPath = confFile.getPath();
|
||||
@NotNull String confName = confFile.getNameWithoutExtension();
|
||||
@NotNull String confPath = confFile.getPath();
|
||||
int level = level(path, confPath);
|
||||
if (level == 0) {
|
||||
continue;
|
||||
@@ -76,12 +76,12 @@ class ConfCacheGetUtils {
|
||||
static <T> TreeMap<String, T> filterPath(@SuppressWarnings("SameParameterValue")
|
||||
@NotNull Map<VirtualFile, T> cache,
|
||||
@NotNull String path, String name, String ext) {
|
||||
TreeMap<String, T> map = new TreeMap<>();
|
||||
@NotNull TreeMap<String, T> map = new TreeMap<>();
|
||||
int max = path.length();
|
||||
int length = String.valueOf(max).length();
|
||||
for (Map.Entry<VirtualFile, T> entry : cache.entrySet()) {
|
||||
for (@NotNull Map.Entry<VirtualFile, T> entry : cache.entrySet()) {
|
||||
VirtualFile confFile = entry.getKey();
|
||||
String confPath = confFile.getPath();
|
||||
@NotNull String confPath = confFile.getPath();
|
||||
int level = level(path, confPath);
|
||||
if (level == 0) {
|
||||
continue;
|
||||
@@ -119,7 +119,7 @@ class ConfCacheGetUtils {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static String srcPath(String path) {
|
||||
private static String srcPath(@NotNull String path) {
|
||||
int i = path.indexOf('!');
|
||||
if (i != -1) {
|
||||
return path.substring(i + 1);
|
||||
@@ -131,7 +131,7 @@ class ConfCacheGetUtils {
|
||||
return path;
|
||||
}
|
||||
|
||||
private static boolean match(String path, String confPath) {
|
||||
private static boolean match(@NotNull String path, @NotNull String confPath) {
|
||||
if (confPath.equals(path) || SKIP_PATH.equals(confPath)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -29,11 +29,11 @@ class ConfFactory {
|
||||
@Nullable
|
||||
static Pattern buildPattern(@Nullable Project project, @NotNull String path,
|
||||
@NotNull Map<String, Map<String, List<String>>> map) {
|
||||
Set<String> exclude = new LinkedSet<>();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (Map<String, List<String>> keyMap : map.values()) {
|
||||
@NotNull Set<String> exclude = new LinkedSet<>();
|
||||
@NotNull StringBuilder sb = new StringBuilder();
|
||||
for (@NotNull Map<String, List<String>> keyMap : map.values()) {
|
||||
// key() is escape
|
||||
for (List<String> list : keyMap.values()) {
|
||||
for (@NotNull List<String> list : keyMap.values()) {
|
||||
String key = list.get(0);
|
||||
if (key.startsWith("?")) {
|
||||
exclude.add(key.substring(1));
|
||||
@@ -45,7 +45,7 @@ class ConfFactory {
|
||||
if (sb.length() > 0) {
|
||||
sb.delete(sb.length() - 1, sb.length());
|
||||
}
|
||||
String regex = sb.toString();
|
||||
@NotNull String regex = sb.toString();
|
||||
Pattern pattern = PATTERN_CACHE.get(regex);
|
||||
if (pattern != null) {
|
||||
return pattern;
|
||||
@@ -54,7 +54,7 @@ class ConfFactory {
|
||||
sb.insert(0, path);
|
||||
sb.insert(0, "\n");
|
||||
try {
|
||||
Pattern compile = Pattern.compile(regex);
|
||||
@NotNull Pattern compile = Pattern.compile(regex);
|
||||
PATTERN_CACHE.put(regex, compile);
|
||||
REGEXP_LOG.createNotification("Ext doc keyword regexp compile success", regex.length() + " chars",
|
||||
sb.toString(), NotificationType.INFORMATION).notify(project);
|
||||
@@ -74,9 +74,9 @@ class ConfFactory {
|
||||
@NotNull
|
||||
static Map<String, List<String>> buildMap(@Nullable Project project, @NotNull String path,
|
||||
@NotNull String[] lines, boolean isKey) {
|
||||
Map<String, List<String>> map = new LinkedHashMap<>();
|
||||
for (String line : lines) {
|
||||
List<String> words = Splitter.on('\t').splitToList(line);
|
||||
@NotNull Map<String, List<String>> map = new LinkedHashMap<>();
|
||||
for (@NotNull String line : lines) {
|
||||
@NotNull List<String> words = Splitter.on('\t').splitToList(line);
|
||||
if (!words.isEmpty()) {
|
||||
String key = words.get(0);
|
||||
if (key.length() == 0) {
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.intellij.openapi.fileEditor.FileEditorManagerEvent;
|
||||
import com.intellij.openapi.fileEditor.FileEditorManagerListener;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* call ConfCache.loadFile
|
||||
@@ -12,7 +13,7 @@ public class ConfFileChangeListener implements FileEditorManagerListener {
|
||||
|
||||
@Override
|
||||
public void selectionChanged(@NotNull FileEditorManagerEvent event) {
|
||||
VirtualFile file = event.getOldFile();
|
||||
@Nullable VirtualFile file = event.getOldFile();
|
||||
if (file == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.vfs.newvfs.BulkFileListener;
|
||||
import com.intellij.openapi.vfs.newvfs.events.*;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -14,18 +15,18 @@ public class ConfFileListener implements BulkFileListener {
|
||||
|
||||
@Override
|
||||
public void after(@NotNull List<? extends VFileEvent> events) {
|
||||
for (VFileEvent event : events) {
|
||||
for (@NotNull VFileEvent event : events) {
|
||||
forEvent(event);
|
||||
}
|
||||
}
|
||||
|
||||
private static void forEvent(VFileEvent event) {
|
||||
VirtualFile file = event.getFile();
|
||||
private static void forEvent(@NotNull VFileEvent event) {
|
||||
@Nullable VirtualFile file = event.getFile();
|
||||
if (file == null) {
|
||||
return;
|
||||
}
|
||||
if (event instanceof VFilePropertyChangeEvent) {
|
||||
VFilePropertyChangeEvent changeEvent = (VFilePropertyChangeEvent) event;
|
||||
@NotNull VFilePropertyChangeEvent changeEvent = (VFilePropertyChangeEvent) event;
|
||||
if ("name".equals(changeEvent.getPropertyName())) {
|
||||
String oldName = changeEvent.getOldValue().toString();
|
||||
if (oldName.endsWith(ConfCache.EXT)) {
|
||||
@@ -45,8 +46,8 @@ public class ConfFileListener implements BulkFileListener {
|
||||
return;
|
||||
}
|
||||
if (event instanceof VFileCopyEvent) {
|
||||
VFileCopyEvent copyEvent = (VFileCopyEvent) event;
|
||||
VirtualFile newFile = copyEvent.findCreatedFile();
|
||||
@NotNull VFileCopyEvent copyEvent = (VFileCopyEvent) event;
|
||||
@Nullable VirtualFile newFile = copyEvent.findCreatedFile();
|
||||
if (newFile == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.intellij.openapi.actionSystem.AnAction;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* call ConfCache.loadAll
|
||||
@@ -11,7 +12,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
public class ReloadExtDocAction extends AnAction {
|
||||
@Override
|
||||
public void actionPerformed(@NotNull AnActionEvent e) {
|
||||
Project project = e.getProject();
|
||||
@Nullable Project project = e.getProject();
|
||||
if (project == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -8,7 +8,9 @@ import java.util.List;
|
||||
|
||||
public class JsonRef<T extends PsiElement> extends PsiReferenceBase<PsiElement> implements PsiPolyVariantReference {
|
||||
|
||||
@NotNull
|
||||
final T psiField;
|
||||
@NotNull
|
||||
final List<T> tips;
|
||||
|
||||
public JsonRef(@NotNull PsiElement element, @NotNull T psiField, @NotNull List<T> tips) {
|
||||
|
||||
@@ -31,7 +31,7 @@ public class GoLangDoc extends BaseLangDoc {
|
||||
|
||||
@Override
|
||||
public @Nullable <T extends SettingsInfo> String resolveDocRaw(@NotNull T lineInfo, @NotNull PsiElement resolve) {
|
||||
List<PsiComment> comments = GoDocumentationProvider.getCommentsForElement(resolve);
|
||||
@NotNull List<PsiComment> comments = GoDocumentationProvider.getCommentsForElement(resolve);
|
||||
return GoDocumentationProvider.getCommentText(comments, false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,12 +29,12 @@ public class JsLangDoc extends BaseLangDoc {
|
||||
|
||||
@Override
|
||||
public @Nullable <T extends SettingsInfo> String resolveDocRaw(@NotNull T lineInfo, @NotNull PsiElement resolve) {
|
||||
PsiComment psiComment = JSDocumentationUtils.findOwnDocCommentForImplicitElement(resolve);
|
||||
@Nullable PsiComment psiComment = JSDocumentationUtils.findOwnDocCommentForImplicitElement(resolve);
|
||||
if (psiComment == null) {
|
||||
return null;
|
||||
}
|
||||
String text = psiComment.getText();
|
||||
if (text!=null) {
|
||||
if (text != null) {
|
||||
return text;
|
||||
}
|
||||
if (!lineInfo.appSettings.jsDoc) {
|
||||
|
||||
@@ -25,7 +25,7 @@ public class JsonLangDoc extends BaseLangDoc {
|
||||
|
||||
@Override
|
||||
public @Nullable String findRefDoc(@NotNull LineInfo lineInfo, @NotNull PsiElement element) {
|
||||
PsiElement start = lineInfo.viewProvider.findElementAt(lineInfo.startOffset);
|
||||
@Nullable PsiElement start = lineInfo.viewProvider.findElementAt(lineInfo.startOffset);
|
||||
if (start == null) {
|
||||
return null;
|
||||
}
|
||||
@@ -41,10 +41,10 @@ public class JsonLangDoc extends BaseLangDoc {
|
||||
if (!(ref instanceof JsonProperty)) {
|
||||
return null;
|
||||
}
|
||||
JsonProperty jsonProperty = (JsonProperty) ref;
|
||||
PsiReference[] references = jsonProperty.getNameElement().getReferences();
|
||||
for (PsiReference reference : references) {
|
||||
PsiElement resolve = null;
|
||||
@NotNull JsonProperty jsonProperty = (JsonProperty) ref;
|
||||
@NotNull PsiReference[] references = jsonProperty.getNameElement().getReferences();
|
||||
for (@NotNull PsiReference reference : references) {
|
||||
@Nullable PsiElement resolve = null;
|
||||
try {
|
||||
resolve = reference.resolve();
|
||||
} catch (Throwable ignore) {
|
||||
@@ -53,7 +53,7 @@ public class JsonLangDoc extends BaseLangDoc {
|
||||
if (resolve == null) {
|
||||
continue;
|
||||
}
|
||||
String doc = BaseLangDoc.resolveDoc(lineInfo, resolve);
|
||||
@Nullable String doc = BaseLangDoc.resolveDoc(lineInfo, resolve);
|
||||
if (doc != null) {
|
||||
return doc;
|
||||
}
|
||||
|
||||
@@ -39,8 +39,8 @@ public class SqlLangDoc extends BaseLangDoc {
|
||||
} catch (Throwable e) {
|
||||
return null;
|
||||
}
|
||||
for (DbElement dbElement : relatedDbElements) {
|
||||
String refDoc = dbElement.getComment();
|
||||
for (@NotNull DbElement dbElement : relatedDbElements) {
|
||||
@Nullable String refDoc = dbElement.getComment();
|
||||
if (refDoc != null && !DocSkip.skipDoc(lineInfo.appSettings, lineInfo.projectSettings, refDoc)) {
|
||||
return refDoc;
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ public abstract class BaseLangDoc extends EditorLinePainter {
|
||||
}
|
||||
|
||||
public static @Nullable String langDoc(@NotNull LineInfo lineInfo) {
|
||||
PsiElement element = lineInfo.viewProvider.findElementAt(lineInfo.endOffset);
|
||||
@Nullable PsiElement element = lineInfo.viewProvider.findElementAt(lineInfo.endOffset);
|
||||
if (element == null) {
|
||||
// file end
|
||||
element = lineInfo.viewProvider.findElementAt(lineInfo.endOffset - 1);
|
||||
@@ -49,7 +49,7 @@ public abstract class BaseLangDoc extends EditorLinePainter {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
Language language = PsiElementTo.language(element);
|
||||
@NotNull Language language = PsiElementTo.language(element);
|
||||
BaseLangDoc lineEnd = LANG_DOC_MAP.get(language.getID());
|
||||
if (lineEnd != null && lineEnd.show(lineInfo)) {
|
||||
return lineEnd.findRefDoc(lineInfo, element);
|
||||
@@ -64,15 +64,15 @@ public abstract class BaseLangDoc extends EditorLinePainter {
|
||||
*/
|
||||
@Nullable
|
||||
public String findRefDoc(@NotNull LineInfo lineInfo, @NotNull PsiElement element) {
|
||||
Class<? extends PsiElement> refClass = getRefClass();
|
||||
@Nullable Class<? extends PsiElement> refClass = getRefClass();
|
||||
if (refClass == null) {
|
||||
return null;
|
||||
}
|
||||
String doc = null;
|
||||
PsiElement refElement = element;
|
||||
@Nullable String doc = null;
|
||||
@Nullable PsiElement refElement = element;
|
||||
while ((refElement = Prev.prevRefChild(lineInfo, refElement, refClass)) != null) {
|
||||
PsiElement parent = refElement.getParent();
|
||||
String filterDoc = refElementDoc(lineInfo, parent);
|
||||
@Nullable String filterDoc = refElementDoc(lineInfo, parent);
|
||||
if (filterDoc != null) {
|
||||
doc = filterDoc;
|
||||
refElement = parent;
|
||||
@@ -90,7 +90,7 @@ public abstract class BaseLangDoc extends EditorLinePainter {
|
||||
String text = refElement.getText();
|
||||
boolean set = text.startsWith("set");
|
||||
PsiElement parent = refElement.getParent();
|
||||
String before = refElementDoc(lineInfo, parent);
|
||||
@Nullable String before = refElementDoc(lineInfo, parent);
|
||||
if (before != null) {
|
||||
doc = mergeDoc(set, lineInfo.appSettings.getToSet, before, doc);
|
||||
}
|
||||
@@ -115,9 +115,10 @@ public abstract class BaseLangDoc extends EditorLinePainter {
|
||||
/**
|
||||
* Override like SQL
|
||||
*/
|
||||
@Nullable
|
||||
protected <T extends SettingsInfo> String refElementDoc(@NotNull T lineInfo,
|
||||
@NotNull PsiElement refElement) {
|
||||
String refDoc = refDoc(lineInfo, refElement);
|
||||
@Nullable String refDoc = refDoc(lineInfo, refElement);
|
||||
if (refDoc != null && !DocSkip.skipDoc(lineInfo.appSettings, lineInfo.projectSettings, refDoc)) {
|
||||
return refDoc;
|
||||
}
|
||||
@@ -130,22 +131,23 @@ public abstract class BaseLangDoc extends EditorLinePainter {
|
||||
@Nullable
|
||||
protected <T extends SettingsInfo> String refDoc(@NotNull T lineInfo, @NotNull PsiElement ref) {
|
||||
// kotlin ref.getReference() == null but ref.getReferences().length == 2
|
||||
PsiReference[] references = ref.getReferences();
|
||||
@NotNull PsiReference[] references = ref.getReferences();
|
||||
if (references.length < 1) {
|
||||
return null;
|
||||
}
|
||||
for (PsiReference reference : references) {
|
||||
PsiElement resolve;
|
||||
for (@NotNull PsiReference reference : references) {
|
||||
@Nullable PsiElement resolve;
|
||||
try {
|
||||
resolve = reference.resolve();
|
||||
} catch (Throwable e) {
|
||||
// 2021.3: Slow operations are prohibited on EDT. See SlowOperations.assertSlowOperationsAreAllowed javadoc.
|
||||
// 2021.3: Slow operations are prohibited on EDT.
|
||||
// See SlowOperations.assertSlowOperationsAreAllowed javadoc.
|
||||
return null;
|
||||
}
|
||||
if (resolve == null) {
|
||||
return null;
|
||||
}
|
||||
String resolveDoc = resolveDoc(lineInfo, resolve);
|
||||
@Nullable String resolveDoc = resolveDoc(lineInfo, resolve);
|
||||
if (resolveDoc != null) {
|
||||
return resolveDoc;
|
||||
}
|
||||
@@ -153,9 +155,10 @@ public abstract class BaseLangDoc extends EditorLinePainter {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static @Nullable <T extends SettingsInfo> String resolveDoc(T settingsInfo, PsiElement psiElement) {
|
||||
public static @Nullable <T extends SettingsInfo> String resolveDoc(@NotNull T settingsInfo,
|
||||
@NotNull PsiElement psiElement) {
|
||||
// support like java <-> kotlin
|
||||
Language language = PsiElementTo.language(psiElement);
|
||||
@NotNull Language language = PsiElementTo.language(psiElement);
|
||||
BaseLangDoc lineEnd = LANG_DOC_MAP.get(language.getID());
|
||||
if (lineEnd == null) {
|
||||
return null;
|
||||
@@ -168,12 +171,12 @@ public abstract class BaseLangDoc extends EditorLinePainter {
|
||||
*/
|
||||
@Nullable
|
||||
protected <T extends SettingsInfo> String resolveDocPrint(@NotNull T lineInfo, @NotNull PsiElement resolve) {
|
||||
String s = resolveDocRaw(lineInfo, resolve);
|
||||
@Nullable String s = resolveDocRaw(lineInfo, resolve);
|
||||
if (s == null) {
|
||||
return null;
|
||||
}
|
||||
String cutDoc = DocFilter.cutDoc(s, lineInfo.appSettings, true);
|
||||
String filterDoc = DocFilter.filterDoc(cutDoc, lineInfo.appSettings, lineInfo.projectSettings);
|
||||
@NotNull String cutDoc = DocFilter.cutDoc(s, lineInfo.appSettings, true);
|
||||
@NotNull String filterDoc = DocFilter.filterDoc(cutDoc, lineInfo.appSettings, lineInfo.projectSettings);
|
||||
if (filterDoc.trim().length() == 0) {
|
||||
return null;
|
||||
}
|
||||
@@ -185,17 +188,18 @@ public abstract class BaseLangDoc extends EditorLinePainter {
|
||||
*/
|
||||
@Nullable
|
||||
protected <T extends SettingsInfo> String resolveDocRaw(@NotNull T lineInfo, @NotNull PsiElement resolve) {
|
||||
FileViewProvider viewProvider = PsiElementTo.viewProvider(resolve);
|
||||
@Nullable FileViewProvider viewProvider = PsiElementTo.viewProvider(resolve);
|
||||
if (viewProvider == null) {
|
||||
return null;
|
||||
}
|
||||
String doc = ResolveDoc.fromLineEnd(lineInfo, resolve, viewProvider);
|
||||
@Nullable String doc = ResolveDoc.fromLineEnd(lineInfo, resolve, viewProvider);
|
||||
if (doc != null) {
|
||||
return doc;
|
||||
}
|
||||
return ResolveDoc.fromLineUp(lineInfo, resolve, viewProvider, keywords());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
protected List<String> keywords() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ public abstract class BaseTagLangDoc<DocElement> extends BaseLangDoc {
|
||||
|
||||
@Override
|
||||
public @Nullable <T extends SettingsInfo> String resolveDocPrint(@NotNull T lineInfo, @NotNull PsiElement resolve) {
|
||||
DocElement docElement = toDocElement(resolve);
|
||||
@Nullable DocElement docElement = toDocElement(resolve);
|
||||
if (docElement == null) {
|
||||
return null;
|
||||
}
|
||||
@@ -22,12 +22,12 @@ public abstract class BaseTagLangDoc<DocElement> extends BaseLangDoc {
|
||||
return null;
|
||||
}
|
||||
// desc
|
||||
String descDoc = descDoc(lineInfo, docElement).trim();
|
||||
String desc = DocFilter.filterDoc(descDoc, lineInfo.appSettings, lineInfo.projectSettings);
|
||||
@NotNull String descDoc = descDoc(lineInfo, docElement).trim();
|
||||
@NotNull String desc = DocFilter.filterDoc(descDoc, lineInfo.appSettings, lineInfo.projectSettings);
|
||||
// tag
|
||||
StringBuilder tagStrBuilder = new StringBuilder();
|
||||
String[] names = lineInfo.tagNames();
|
||||
for (String name : names) {
|
||||
@NotNull StringBuilder tagStrBuilder = new StringBuilder();
|
||||
@NotNull String[] names = lineInfo.tagNames();
|
||||
for (@NotNull String name : names) {
|
||||
appendTag(lineInfo, tagStrBuilder, docElement, name);
|
||||
}
|
||||
if (desc.length() > 0) {
|
||||
@@ -36,7 +36,7 @@ public abstract class BaseTagLangDoc<DocElement> extends BaseLangDoc {
|
||||
}
|
||||
tagStrBuilder.insert(0, desc);
|
||||
}
|
||||
String text = tagStrBuilder.toString().trim();
|
||||
@NotNull String text = tagStrBuilder.toString().trim();
|
||||
if (text.length() == 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ package io.github.linwancen.plugin.show.lang.base;
|
||||
import io.github.linwancen.plugin.show.settings.AppSettingsState;
|
||||
import io.github.linwancen.plugin.show.settings.ProjectSettingsState;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
@@ -33,10 +32,10 @@ public class DocFilter {
|
||||
*/
|
||||
@NotNull
|
||||
public static String cutDoc(String text,
|
||||
AppSettingsState appSettings, boolean deletePrefix) {
|
||||
@NotNull AppSettingsState appSettings, boolean deletePrefix) {
|
||||
String[] split = LINE_SEPARATOR_PATTERN.split(text);
|
||||
int lineCount = 0;
|
||||
StringBuilder sb = new StringBuilder();
|
||||
@NotNull StringBuilder sb = new StringBuilder();
|
||||
for (String s : split) {
|
||||
if (deletePrefix) {
|
||||
s = DOC_PATTERN.matcher(s).replaceAll("");
|
||||
@@ -64,8 +63,8 @@ public class DocFilter {
|
||||
*/
|
||||
@NotNull
|
||||
public static String filterDoc(@NotNull String text,
|
||||
AppSettingsState appSettings,
|
||||
ProjectSettingsState projectSettings) {
|
||||
@NotNull AppSettingsState appSettings,
|
||||
@NotNull ProjectSettingsState projectSettings) {
|
||||
// docGetEffect first because default false
|
||||
if (projectSettings.docGetEffect && projectSettings.projectFilterEffective) {
|
||||
return filterDoc(text, projectSettings.docGet);
|
||||
@@ -79,7 +78,7 @@ public class DocFilter {
|
||||
@NotNull
|
||||
public static String filterDoc(@NotNull String text, @NotNull Pattern docGet) {
|
||||
// if effect skip check empty
|
||||
Matcher m = docGet.matcher(text);
|
||||
@NotNull Matcher m = docGet.matcher(text);
|
||||
if (m.find()) {
|
||||
return m.group(m.groupCount());
|
||||
}
|
||||
@@ -93,7 +92,7 @@ public class DocFilter {
|
||||
* trim end with space
|
||||
*/
|
||||
public static void addHtml(@NotNull StringBuilder sb, @NotNull String s) {
|
||||
String deleteHtml = HTML_PATTERN.matcher(s).replaceAll("").trim();
|
||||
@NotNull String deleteHtml = HTML_PATTERN.matcher(s).replaceAll("").trim();
|
||||
if (deleteHtml.length() > 0) {
|
||||
sb.append(deleteHtml).append(" ");
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package io.github.linwancen.plugin.show.lang.base;
|
||||
import io.github.linwancen.plugin.show.settings.AppSettingsState;
|
||||
import io.github.linwancen.plugin.show.settings.ProjectSettingsState;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
@@ -10,7 +11,8 @@ public class DocSkip {
|
||||
|
||||
private DocSkip() {}
|
||||
|
||||
public static boolean skipSign(AppSettingsState appSettings, ProjectSettingsState projectSettings, String text) {
|
||||
public static boolean skipSign(@NotNull AppSettingsState appSettings,
|
||||
@NotNull ProjectSettingsState projectSettings, String text) {
|
||||
return skipText(text,
|
||||
projectSettings.globalFilterEffective, appSettings.lineInclude, appSettings.lineExclude,
|
||||
projectSettings.projectFilterEffective, projectSettings.lineInclude, projectSettings.lineExclude);
|
||||
@@ -18,7 +20,8 @@ public class DocSkip {
|
||||
|
||||
private static final Pattern NOT_ASCII_PATTERN = Pattern.compile("[^\u0000-\u007f]");
|
||||
|
||||
public static boolean skipDoc(AppSettingsState appSettings, ProjectSettingsState projectSettings, String text) {
|
||||
public static boolean skipDoc(@NotNull AppSettingsState appSettings,
|
||||
@NotNull ProjectSettingsState projectSettings, @NotNull String text) {
|
||||
if (appSettings.skipAscii && !NOT_ASCII_PATTERN.matcher(text).find()) {
|
||||
return true;
|
||||
}
|
||||
@@ -27,9 +30,10 @@ public class DocSkip {
|
||||
projectSettings.projectFilterEffective, projectSettings.docInclude, projectSettings.docExclude);
|
||||
}
|
||||
|
||||
static boolean skipText(String text,
|
||||
boolean appFilterEffective, Pattern appDocInclude, Pattern appDocExclude,
|
||||
boolean projectFilterEffective, Pattern projectDocInclude, Pattern projectDocExclude
|
||||
static boolean skipText(@Nullable String text,
|
||||
boolean appFilterEffective, @NotNull Pattern appDocInclude, @NotNull Pattern appDocExclude,
|
||||
boolean projectFilterEffective, @NotNull Pattern projectDocInclude,
|
||||
@NotNull Pattern projectDocExclude
|
||||
) {
|
||||
if (text == null) {
|
||||
return true;
|
||||
@@ -44,21 +48,21 @@ public class DocSkip {
|
||||
return false;
|
||||
}
|
||||
|
||||
static boolean skipText(@NotNull String text, Pattern include, Pattern exclude) {
|
||||
static boolean skipText(@NotNull String text, @NotNull Pattern include, @NotNull Pattern exclude) {
|
||||
if (exclude(text, exclude)) {
|
||||
return true;
|
||||
}
|
||||
return !include(text, include);
|
||||
}
|
||||
|
||||
static boolean include(@NotNull String text, Pattern include) {
|
||||
static boolean include(@NotNull String text, @NotNull Pattern include) {
|
||||
if (include.pattern().length() == 0) {
|
||||
return true;
|
||||
}
|
||||
return include.matcher(text).find();
|
||||
}
|
||||
|
||||
static boolean exclude(@NotNull String text, Pattern exclude) {
|
||||
static boolean exclude(@NotNull String text, @NotNull Pattern exclude) {
|
||||
if (exclude.pattern().length() == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ public class Prev {
|
||||
|
||||
private Prev() {}
|
||||
|
||||
@Nullable
|
||||
public static PsiElement prevRefChild(@NotNull LineInfo lineInfo, @NotNull PsiElement element,
|
||||
@NotNull Class<? extends PsiElement> refClass) {
|
||||
PsiElement prevParent = element.getParent();
|
||||
@@ -22,7 +23,7 @@ public class Prev {
|
||||
if (element.getTextRange().getEndOffset() < lineInfo.startOffset) {
|
||||
return null;
|
||||
}
|
||||
PsiElement parent = refClassParent(element, refClass);
|
||||
@Nullable PsiElement parent = refClassParent(element, refClass);
|
||||
if (parent != null) {
|
||||
// skip b in a.b.c
|
||||
if (prevParent.getTextRange().getEndOffset() < lineInfo.endOffset
|
||||
@@ -42,6 +43,7 @@ public class Prev {
|
||||
"{-~" +
|
||||
"]++");
|
||||
|
||||
@Nullable
|
||||
private static PsiElement refClassParent(@NotNull PsiElement element,
|
||||
@NotNull Class<? extends PsiElement> refClass) {
|
||||
String text = element.getText();
|
||||
@@ -67,7 +69,7 @@ public class Prev {
|
||||
|
||||
public static @Nullable <T extends SettingsInfo> PsiElement prevCompactElement(
|
||||
@SuppressWarnings("unused") @NotNull T lineInfo, @NotNull PsiElement resolve, @NotNull Document document) {
|
||||
PsiElement element = PsiTreeUtil.prevVisibleLeaf(resolve);
|
||||
@Nullable PsiElement element = PsiTreeUtil.prevVisibleLeaf(resolve);
|
||||
if (element == null) {
|
||||
return null;
|
||||
}
|
||||
@@ -79,7 +81,7 @@ public class Prev {
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
String replace = spaceText.replace("\n", "");
|
||||
@NotNull String replace = spaceText.replace("\n", "");
|
||||
if (spaceText.length() - replace.length() > 1) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ public class PsiElementTo {
|
||||
|
||||
private PsiElementTo() {}
|
||||
|
||||
public static @Nullable FileViewProvider viewProvider(PsiElement resolve) {
|
||||
public static @Nullable FileViewProvider viewProvider(@NotNull PsiElement resolve) {
|
||||
PsiFile psiFile = resolve.getContainingFile();
|
||||
if (psiFile == null) {
|
||||
return null;
|
||||
@@ -26,8 +26,8 @@ public class PsiElementTo {
|
||||
}
|
||||
|
||||
public static @NotNull Language language(@NotNull PsiElement element) {
|
||||
Language lang = element.getLanguage();
|
||||
Language base = lang.getBaseLanguage();
|
||||
@NotNull Language lang = element.getLanguage();
|
||||
@Nullable Language base = lang.getBaseLanguage();
|
||||
if (base != null) {
|
||||
return base;
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ public class ResolveDoc {
|
||||
public static <T extends SettingsInfo> String fromLineEnd(@SuppressWarnings("unused") @NotNull T lineInfo,
|
||||
@NotNull PsiElement resolve,
|
||||
@NotNull FileViewProvider resolveViewProvider) {
|
||||
Document document = resolveViewProvider.getDocument();
|
||||
@Nullable Document document = resolveViewProvider.getDocument();
|
||||
if (document == null) {
|
||||
return null;
|
||||
}
|
||||
@@ -33,11 +33,11 @@ public class ResolveDoc {
|
||||
return null;
|
||||
}
|
||||
// end over will return last
|
||||
PsiElement psiElement = resolveViewProvider.findElementAt(resolveEndOffset);
|
||||
@Nullable PsiElement psiElement = resolveViewProvider.findElementAt(resolveEndOffset);
|
||||
if (psiElement == null) {
|
||||
return null;
|
||||
}
|
||||
PsiElement docElement = PsiTreeUtil.prevVisibleLeaf(psiElement);
|
||||
@Nullable PsiElement docElement = PsiTreeUtil.prevVisibleLeaf(psiElement);
|
||||
if (!(docElement instanceof PsiComment)) {
|
||||
return null;
|
||||
}
|
||||
@@ -51,14 +51,14 @@ public class ResolveDoc {
|
||||
|
||||
@Nullable
|
||||
public static <T extends SettingsInfo> String fromLineUp(@NotNull T lineInfo,
|
||||
PsiElement resolve,
|
||||
@NotNull PsiElement resolve,
|
||||
@NotNull FileViewProvider resolveViewProvider,
|
||||
@NotNull List<String> keywords) {
|
||||
Document document = resolveViewProvider.getDocument();
|
||||
@Nullable Document document = resolveViewProvider.getDocument();
|
||||
if (document == null) {
|
||||
return null;
|
||||
}
|
||||
PsiElement psiElement = Prev.prevCompactElement(lineInfo, resolve, document);
|
||||
@Nullable PsiElement psiElement = Prev.prevCompactElement(lineInfo, resolve, document);
|
||||
if (!keywords.isEmpty()) {
|
||||
while (psiElement != null) {
|
||||
String text = psiElement.getText();
|
||||
@@ -69,7 +69,7 @@ public class ResolveDoc {
|
||||
}
|
||||
}
|
||||
}
|
||||
StringBuilder sb = new StringBuilder();
|
||||
@NotNull StringBuilder sb = new StringBuilder();
|
||||
while (psiElement instanceof PsiComment) {
|
||||
String text = psiElement.getText();
|
||||
if (text != null) {
|
||||
|
||||
@@ -38,7 +38,8 @@ public abstract class AbstractSettingsComponent {
|
||||
return lineEndFilter;
|
||||
}
|
||||
|
||||
protected FormBuilder add(FormBuilder formBuilder, JBCheckBox jbCheckBox, JBTextField jbTextField, String tip) {
|
||||
protected FormBuilder add(@NotNull FormBuilder formBuilder, JBCheckBox jbCheckBox,
|
||||
@NotNull JBTextField jbTextField, @NotNull String tip) {
|
||||
return formBuilder.addLabeledComponent(JPanelFactory.of(jbCheckBox, new JBLabel(tip)), jbTextField, 1, true);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
package io.github.linwancen.plugin.show.settings;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class AbstractSettingsConfigurable {
|
||||
|
||||
private AbstractSettingsConfigurable() {}
|
||||
|
||||
static boolean isModified(AbstractSettingsState settings, AbstractSettingsComponent component, boolean modified) {
|
||||
static boolean isModified(@NotNull AbstractSettingsState settings, @NotNull AbstractSettingsComponent component,
|
||||
boolean modified) {
|
||||
modified |= !component.getLineInclude().equals(settings.getLineInclude());
|
||||
modified |= !component.getLineExclude().equals(settings.getLineExclude());
|
||||
modified |= !component.getDocInclude().equals(settings.getDocInclude());
|
||||
@@ -14,7 +17,7 @@ public class AbstractSettingsConfigurable {
|
||||
return modified;
|
||||
}
|
||||
|
||||
static void apply(AbstractSettingsState settings, AbstractSettingsComponent component) {
|
||||
static void apply(@NotNull AbstractSettingsState settings, @NotNull AbstractSettingsComponent component) {
|
||||
settings.setLineInclude(component.getLineInclude());
|
||||
settings.setLineExclude(component.getLineExclude());
|
||||
settings.setDocInclude(component.getDocInclude());
|
||||
@@ -23,7 +26,7 @@ public class AbstractSettingsConfigurable {
|
||||
settings.setDocGet(component.getDocGet());
|
||||
}
|
||||
|
||||
static void reset(AbstractSettingsState settings, AbstractSettingsComponent component) {
|
||||
static void reset(@NotNull AbstractSettingsState settings, @NotNull AbstractSettingsComponent component) {
|
||||
component.setLineInclude(settings.getLineInclude());
|
||||
component.setLineExclude(settings.getLineExclude());
|
||||
component.setDocInclude(settings.getDocInclude());
|
||||
|
||||
@@ -1,21 +1,28 @@
|
||||
package io.github.linwancen.plugin.show.settings;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public abstract class AbstractSettingsState {
|
||||
|
||||
@NotNull
|
||||
public transient Pattern lineInclude = Pattern.compile("");
|
||||
@NotNull
|
||||
public transient Pattern lineExclude = Pattern.compile("^java");
|
||||
@NotNull
|
||||
public transient Pattern docInclude = Pattern.compile("");
|
||||
@NotNull
|
||||
public transient Pattern docExclude = Pattern.compile("");
|
||||
public transient boolean docGetEffect = false;
|
||||
@NotNull
|
||||
public transient Pattern docGet = Pattern.compile(".+?(?:[。\\r\\n]|\\. )");
|
||||
|
||||
public String getLineInclude() {
|
||||
return lineInclude.pattern();
|
||||
}
|
||||
|
||||
public void setLineInclude(String lineInclude) {
|
||||
public void setLineInclude(@NotNull String lineInclude) {
|
||||
this.lineInclude = Pattern.compile(lineInclude);
|
||||
}
|
||||
|
||||
@@ -23,7 +30,7 @@ public abstract class AbstractSettingsState {
|
||||
return lineExclude.pattern();
|
||||
}
|
||||
|
||||
public void setLineExclude(String lineExclude) {
|
||||
public void setLineExclude(@NotNull String lineExclude) {
|
||||
this.lineExclude = Pattern.compile(lineExclude);
|
||||
}
|
||||
|
||||
@@ -32,7 +39,7 @@ public abstract class AbstractSettingsState {
|
||||
return docInclude.pattern();
|
||||
}
|
||||
|
||||
public void setDocInclude(String docInclude) {
|
||||
public void setDocInclude(@NotNull String docInclude) {
|
||||
this.docInclude = Pattern.compile(docInclude);
|
||||
}
|
||||
|
||||
@@ -40,7 +47,7 @@ public abstract class AbstractSettingsState {
|
||||
return docExclude.pattern();
|
||||
}
|
||||
|
||||
public void setDocExclude(String docExclude) {
|
||||
public void setDocExclude(@NotNull String docExclude) {
|
||||
this.docExclude = Pattern.compile(docExclude);
|
||||
}
|
||||
|
||||
@@ -49,7 +56,7 @@ public abstract class AbstractSettingsState {
|
||||
return docGet.pattern();
|
||||
}
|
||||
|
||||
public void setDocGet(String docExclude) {
|
||||
public void setDocGet(@NotNull String docExclude) {
|
||||
this.docGet = Pattern.compile(docExclude);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import com.intellij.ui.components.JBLabel;
|
||||
import com.intellij.ui.components.JBTextField;
|
||||
import com.intellij.util.ui.FormBuilder;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
@@ -69,15 +70,13 @@ public class AppSettingsComponent extends AbstractSettingsComponent {
|
||||
|
||||
@NotNull
|
||||
protected JPanel lineEndFilterPanel() {
|
||||
JPanel text = JPanelFactory.of(
|
||||
@NotNull JPanel text = JPanelFactory.of(
|
||||
new JBLabel("line count: "), lineEndCount,
|
||||
new JBLabel("text color: "), lineEndColor,
|
||||
new JBLabel("json text color: "), lineEndJsonColor,
|
||||
new JBLabel("prefix: "), lineEndPrefix);
|
||||
FormBuilder formBuilder = FormBuilder.createFormBuilder()
|
||||
// .addComponent(JPanelFactory.of(findElementRightToLeft))
|
||||
.addSeparator()
|
||||
// .addComponent(JPanelFactory.of(fromCall, fromNew, fromRef, inJson, skipAnnotation, skipAscii, skipBlank), 1)
|
||||
.addComponent(JPanelFactory.of(fromNew, fromParam, getToSet, skipAnnotation, skipAscii, skipBlank), 1)
|
||||
.addSeparator()
|
||||
.addComponent(text)
|
||||
@@ -89,6 +88,7 @@ public class AppSettingsComponent extends AbstractSettingsComponent {
|
||||
return myMainPanel;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public JComponent getPreferredFocusedComponent() {
|
||||
return showTreeComment;
|
||||
}
|
||||
@@ -248,6 +248,7 @@ public class AppSettingsComponent extends AbstractSettingsComponent {
|
||||
skipBlank.setSelected(newStatus);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Color getLineEndColor() {
|
||||
return lineEndColor.getSelectedColor();
|
||||
}
|
||||
@@ -256,6 +257,7 @@ public class AppSettingsComponent extends AbstractSettingsComponent {
|
||||
lineEndColor.setSelectedColor(color);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Color getLineEndJsonColor() {
|
||||
return lineEndJsonColor.getSelectedColor();
|
||||
}
|
||||
|
||||
@@ -2,19 +2,24 @@ package io.github.linwancen.plugin.show.settings;
|
||||
|
||||
import com.google.common.base.Splitter;
|
||||
import com.intellij.openapi.options.Configurable;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
public class AppSettingsConfigurable implements Configurable {
|
||||
|
||||
@SuppressWarnings("NotNullFieldNotInitialized")
|
||||
@NotNull
|
||||
private AppSettingsComponent mySettingsComponent;
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
return "Show Comment Global.";
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public JComponent getPreferredFocusedComponent() {
|
||||
return mySettingsComponent.getPreferredFocusedComponent();
|
||||
@@ -29,7 +34,7 @@ public class AppSettingsConfigurable implements Configurable {
|
||||
|
||||
@Override
|
||||
public boolean isModified() {
|
||||
AppSettingsState settings = AppSettingsState.getInstance();
|
||||
@NotNull AppSettingsState settings = AppSettingsState.getInstance();
|
||||
boolean modified = mySettingsComponent.getShowTreeComment() != settings.showTreeComment;
|
||||
modified |= mySettingsComponent.getCompact() != settings.compact;
|
||||
|
||||
@@ -47,8 +52,8 @@ public class AppSettingsConfigurable implements Configurable {
|
||||
modified |= !mySettingsComponent.getLineTags().equals(String.join("|", settings.lineTags));
|
||||
|
||||
modified |= !mySettingsComponent.getLineEndCount().equals(String.valueOf(settings.lineEndCount));
|
||||
modified |= !mySettingsComponent.getLineEndColor().equals(settings.lineEndTextAttr.getForegroundColor());
|
||||
modified |= !mySettingsComponent.getLineEndJsonColor().equals(settings.lineEndJsonTextAttr.getForegroundColor());
|
||||
modified |= !settings.lineEndTextAttr.getForegroundColor().equals(mySettingsComponent.getLineEndColor());
|
||||
modified |= !settings.lineEndJsonTextAttr.getForegroundColor().equals(mySettingsComponent.getLineEndJsonColor());
|
||||
modified |= !mySettingsComponent.getLineEndPrefix().equals(settings.lineEndPrefix);
|
||||
|
||||
modified |= mySettingsComponent.getGetToSet() != settings.getToSet;
|
||||
@@ -65,7 +70,7 @@ public class AppSettingsConfigurable implements Configurable {
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
AppSettingsState settings = AppSettingsState.getInstance();
|
||||
@NotNull AppSettingsState settings = AppSettingsState.getInstance();
|
||||
settings.showTreeComment = mySettingsComponent.getShowTreeComment();
|
||||
settings.compact = mySettingsComponent.getCompact();
|
||||
|
||||
@@ -103,7 +108,7 @@ public class AppSettingsConfigurable implements Configurable {
|
||||
|
||||
@Override
|
||||
public void reset() {
|
||||
AppSettingsState settings = AppSettingsState.getInstance();
|
||||
@NotNull AppSettingsState settings = AppSettingsState.getInstance();
|
||||
mySettingsComponent.setShowTreeComment(settings.showTreeComment);
|
||||
mySettingsComponent.setCompact(settings.compact);
|
||||
|
||||
@@ -137,6 +142,7 @@ public class AppSettingsConfigurable implements Configurable {
|
||||
|
||||
@Override
|
||||
public void disposeUIResources() {
|
||||
//noinspection ConstantConditions
|
||||
mySettingsComponent = null;
|
||||
}
|
||||
|
||||
|
||||
@@ -34,7 +34,9 @@ public class AppSettingsState extends AbstractSettingsState implements Persisten
|
||||
public boolean showLineEndCommentGo = true;
|
||||
public boolean showLineEndCommentKotlin = true;
|
||||
|
||||
@NotNull
|
||||
public String[] treeTags = {"author"};
|
||||
@NotNull
|
||||
public String[] lineTags = {};
|
||||
|
||||
public final TextAttributes lineEndTextAttr = new TextAttributes(
|
||||
@@ -43,6 +45,7 @@ public class AppSettingsState extends AbstractSettingsState implements Persisten
|
||||
public final TextAttributes lineEndJsonTextAttr = new TextAttributes(new JBColor(Gray._140, Gray._140),
|
||||
null, null, null, Font.ITALIC);
|
||||
|
||||
@NotNull
|
||||
public String lineEndPrefix = " // ";
|
||||
public int lineEndCount = 2;
|
||||
public int lineEndLen = 0;
|
||||
@@ -53,6 +56,7 @@ public class AppSettingsState extends AbstractSettingsState implements Persisten
|
||||
public boolean skipAscii = !"en".equals(Locale.getDefault().getLanguage());
|
||||
public boolean skipBlank = true;
|
||||
|
||||
@NotNull
|
||||
public static AppSettingsState getInstance() {
|
||||
AppSettingsState service = ApplicationManager.getApplication().getService(AppSettingsState.class);
|
||||
if (service == null) {
|
||||
@@ -72,20 +76,22 @@ public class AppSettingsState extends AbstractSettingsState implements Persisten
|
||||
XmlSerializerUtil.copyBean(state, this);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String getLineEndColor() {
|
||||
return Integer.toHexString(lineEndTextAttr.getForegroundColor().getRGB()).toUpperCase();
|
||||
}
|
||||
|
||||
public void setLineEndColor(String s) {
|
||||
public void setLineEndColor(@NotNull String s) {
|
||||
int rgb = new BigInteger(s, 16).intValue();
|
||||
lineEndTextAttr.setForegroundColor(new JBColor(new Color(rgb), new Color(rgb)));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String getLineEndJsonColor() {
|
||||
return Integer.toHexString(lineEndJsonTextAttr.getForegroundColor().getRGB()).toUpperCase();
|
||||
}
|
||||
|
||||
public void setLineEndJsonColor(String s) {
|
||||
public void setLineEndJsonColor(@NotNull String s) {
|
||||
int rgb = new BigInteger(s, 16).intValue();
|
||||
lineEndJsonTextAttr.setForegroundColor(new JBColor(new Color(rgb), new Color(rgb)));
|
||||
}
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
package io.github.linwancen.plugin.show.settings;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
|
||||
@@ -7,9 +10,10 @@ public class JPanelFactory {
|
||||
|
||||
private JPanelFactory() {}
|
||||
|
||||
public static JPanel of(Component... components) {
|
||||
JPanel jPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
|
||||
for (Component component : components) {
|
||||
@NotNull
|
||||
public static JPanel of(@NotNull Component... components) {
|
||||
@NotNull JPanel jPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
|
||||
for (@Nullable Component component : components) {
|
||||
if (component != null) {
|
||||
jPanel.add(component);
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@ public class ProjectSettingsComponent extends AbstractSettingsComponent {
|
||||
return myMainPanel;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public JComponent getPreferredFocusedComponent() {
|
||||
return projectFilterEffective;
|
||||
}
|
||||
|
||||
@@ -16,17 +16,21 @@ public class ProjectSettingsConfigurable extends ModuleAwareProjectConfigurable<
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected ProjectSettingsConfigurable createModuleConfigurable(Module module) {
|
||||
protected ProjectSettingsConfigurable createModuleConfigurable(@NotNull Module module) {
|
||||
return new ProjectSettingsConfigurable(module.getProject());
|
||||
}
|
||||
|
||||
@SuppressWarnings("NotNullFieldNotInitialized")
|
||||
@NotNull
|
||||
private ProjectSettingsComponent mySettingsComponent;
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
return "Show Comment Project.";
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public JComponent getPreferredFocusedComponent() {
|
||||
return mySettingsComponent.getPreferredFocusedComponent();
|
||||
@@ -41,7 +45,7 @@ public class ProjectSettingsConfigurable extends ModuleAwareProjectConfigurable<
|
||||
|
||||
@Override
|
||||
public boolean isModified() {
|
||||
ProjectSettingsState settings = ProjectSettingsState.getInstance(getProject());
|
||||
@NotNull ProjectSettingsState settings = ProjectSettingsState.getInstance(getProject());
|
||||
boolean modified = mySettingsComponent.getGlobalFilterEffective() != settings.globalFilterEffective;
|
||||
modified |= mySettingsComponent.getProjectFilterEffective() != settings.projectFilterEffective;
|
||||
modified = AbstractSettingsConfigurable.isModified(settings, mySettingsComponent, modified);
|
||||
@@ -50,7 +54,7 @@ public class ProjectSettingsConfigurable extends ModuleAwareProjectConfigurable<
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
ProjectSettingsState settings = ProjectSettingsState.getInstance(getProject());
|
||||
@NotNull ProjectSettingsState settings = ProjectSettingsState.getInstance(getProject());
|
||||
settings.globalFilterEffective = mySettingsComponent.getGlobalFilterEffective();
|
||||
settings.projectFilterEffective = mySettingsComponent.getProjectFilterEffective();
|
||||
AbstractSettingsConfigurable.apply(settings, mySettingsComponent);
|
||||
@@ -58,7 +62,7 @@ public class ProjectSettingsConfigurable extends ModuleAwareProjectConfigurable<
|
||||
|
||||
@Override
|
||||
public void reset() {
|
||||
ProjectSettingsState settings = ProjectSettingsState.getInstance(getProject());
|
||||
@NotNull ProjectSettingsState settings = ProjectSettingsState.getInstance(getProject());
|
||||
mySettingsComponent.setGlobalFilterEffective(settings.globalFilterEffective);
|
||||
mySettingsComponent.setProjectFilterEffective(settings.projectFilterEffective);
|
||||
AbstractSettingsConfigurable.reset(settings, mySettingsComponent);
|
||||
@@ -66,6 +70,7 @@ public class ProjectSettingsConfigurable extends ModuleAwareProjectConfigurable<
|
||||
|
||||
@Override
|
||||
public void disposeUIResources() {
|
||||
//noinspection ConstantConditions
|
||||
mySettingsComponent = null;
|
||||
}
|
||||
|
||||
|
||||
@@ -12,11 +12,12 @@ import org.jetbrains.annotations.Nullable;
|
||||
name = "io.github.linwancen.plugin.show.settings.ProjectSettingsState",
|
||||
storages = @Storage("ShowCommentProject.xml")
|
||||
)
|
||||
public class ProjectSettingsState extends AbstractSettingsState implements PersistentStateComponent<ProjectSettingsState> {
|
||||
public class ProjectSettingsState extends AbstractSettingsState implements PersistentStateComponent<ProjectSettingsState> {
|
||||
|
||||
public boolean globalFilterEffective = true;
|
||||
public boolean projectFilterEffective = false;
|
||||
|
||||
@NotNull
|
||||
public static ProjectSettingsState getInstance(@NotNull Project project) {
|
||||
ProjectSettingsState service = project.getService(ProjectSettingsState.class);
|
||||
if (service == null) {
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
<idea-plugin url="https://plugins.jetbrains.com/plugin/18553-show-comment">
|
||||
<id>io.github.linwancen.show-comment</id>
|
||||
<name>Show Comment</name>
|
||||
<vendor email="1498425439@qq.com" url="https://github.com/LinWanCen/show-comment">林万程</vendor>
|
||||
<id>io.github.linwancen.show-comment</id>
|
||||
<name>Show Comment</name>
|
||||
<vendor email="1498425439@qq.com" url="https://github.com/LinWanCen/show-comment">林万程</vendor>
|
||||
|
||||
<description><![CDATA[
|
||||
<description><![CDATA[
|
||||
Show doc comment at the Project view Tree, line End, json etc.
|
||||
<ul>
|
||||
<li>"xx-ClassNameOrSimpleName.json" and jump to field
|
||||
@@ -53,79 +53,79 @@ Show doc comment at the Project view Tree, line End, json etc.
|
||||
主页一个 Start,您的支持是项目前进的动力。
|
||||
]]></description>
|
||||
|
||||
<!-- please see https://plugins.jetbrains.com/docs/intellij/plugin-compatibility.html
|
||||
on how to target different products -->
|
||||
<depends optional="true" config-file="java.xml">com.intellij.modules.java</depends>
|
||||
<depends optional="true" config-file="sql.xml">com.intellij.database</depends>
|
||||
<depends optional="true" config-file="js.xml">JavaScript</depends>
|
||||
<depends optional="true" config-file="python.xml">com.intellij.modules.python</depends>
|
||||
<depends optional="true" config-file="go.xml">org.jetbrains.plugins.go</depends>
|
||||
<depends optional="true" config-file="kotlin.xml">org.jetbrains.kotlin</depends>
|
||||
<!--suppress PluginXmlValidity, MybatisMapperXmlInspection -->
|
||||
<!--<depends optional="true" config-file="cs.xml">com.intellij.modules.rider</depends>-->
|
||||
<!-- please see https://plugins.jetbrains.com/docs/intellij/plugin-compatibility.html
|
||||
on how to target different products -->
|
||||
<depends optional="true" config-file="java.xml">com.intellij.modules.java</depends>
|
||||
<depends optional="true" config-file="sql.xml">com.intellij.database</depends>
|
||||
<depends optional="true" config-file="js.xml">JavaScript</depends>
|
||||
<depends optional="true" config-file="python.xml">com.intellij.modules.python</depends>
|
||||
<depends optional="true" config-file="go.xml">org.jetbrains.plugins.go</depends>
|
||||
<depends optional="true" config-file="kotlin.xml">org.jetbrains.kotlin</depends>
|
||||
<!--suppress PluginXmlValidity, MybatisMapperXmlInspection -->
|
||||
<!--<depends optional="true" config-file="cs.xml">com.intellij.modules.rider</depends>-->
|
||||
|
||||
<applicationListeners>
|
||||
<listener class="io.github.linwancen.plugin.show.ext.conf.ConfFileListener"
|
||||
topic="com.intellij.openapi.vfs.newvfs.BulkFileListener"/>
|
||||
<listener class="io.github.linwancen.plugin.show.ext.conf.ConfFileChangeListener"
|
||||
topic="com.intellij.openapi.fileEditor.FileEditorManagerListener"/>
|
||||
</applicationListeners>
|
||||
<applicationListeners>
|
||||
<listener class="io.github.linwancen.plugin.show.ext.conf.ConfFileListener"
|
||||
topic="com.intellij.openapi.vfs.newvfs.BulkFileListener"/>
|
||||
<listener class="io.github.linwancen.plugin.show.ext.conf.ConfFileChangeListener"
|
||||
topic="com.intellij.openapi.fileEditor.FileEditorManagerListener"/>
|
||||
</applicationListeners>
|
||||
|
||||
<projectListeners>
|
||||
<listener class="io.github.linwancen.plugin.show.ext.conf.ConfFileInitListener"
|
||||
topic="com.intellij.openapi.project.ProjectManagerListener"/>
|
||||
</projectListeners>
|
||||
<projectListeners>
|
||||
<listener class="io.github.linwancen.plugin.show.ext.conf.ConfFileInitListener"
|
||||
topic="com.intellij.openapi.project.ProjectManagerListener"/>
|
||||
</projectListeners>
|
||||
|
||||
<extensions defaultExtensionNs="com.intellij">
|
||||
<editor.linePainter implementation="io.github.linwancen.plugin.show.LineEnd"/>
|
||||
<projectViewNodeDecorator implementation="io.github.linwancen.plugin.show.Tree"/>
|
||||
<defaultLiveTemplates file="/liveTemplates/show-comment-doc.xml"/>
|
||||
<defaultLiveTemplates file="/liveTemplates/show-comment-xml.xml"/>
|
||||
<extensions defaultExtensionNs="com.intellij">
|
||||
<editor.linePainter implementation="io.github.linwancen.plugin.show.LineEnd"/>
|
||||
<projectViewNodeDecorator implementation="io.github.linwancen.plugin.show.Tree"/>
|
||||
<defaultLiveTemplates file="/liveTemplates/show-comment-doc.xml"/>
|
||||
<defaultLiveTemplates file="/liveTemplates/show-comment-xml.xml"/>
|
||||
|
||||
<applicationConfigurable parentId="tools"
|
||||
instance="io.github.linwancen.plugin.show.settings.AppSettingsConfigurable"
|
||||
id="io.github.linwancen.plugin.show.settings.AppSettingsConfigurable"
|
||||
displayName="// Show Comment Global"/>
|
||||
<applicationService serviceImplementation="io.github.linwancen.plugin.show.settings.AppSettingsState"/>
|
||||
<projectConfigurable parentId="tools"
|
||||
instance="io.github.linwancen.plugin.show.settings.ProjectSettingsConfigurable"
|
||||
id="io.github.linwancen.plugin.show.settings.ProjectSettingsConfigurable"
|
||||
displayName="// Show Comment Project"/>
|
||||
<projectService serviceImplementation="io.github.linwancen.plugin.show.settings.ProjectSettingsState"/>
|
||||
</extensions>
|
||||
<applicationConfigurable parentId="tools"
|
||||
instance="io.github.linwancen.plugin.show.settings.AppSettingsConfigurable"
|
||||
id="io.github.linwancen.plugin.show.settings.AppSettingsConfigurable"
|
||||
displayName="// Show Comment Global"/>
|
||||
<applicationService serviceImplementation="io.github.linwancen.plugin.show.settings.AppSettingsState"/>
|
||||
<projectConfigurable parentId="tools"
|
||||
instance="io.github.linwancen.plugin.show.settings.ProjectSettingsConfigurable"
|
||||
id="io.github.linwancen.plugin.show.settings.ProjectSettingsConfigurable"
|
||||
displayName="// Show Comment Project"/>
|
||||
<projectService serviceImplementation="io.github.linwancen.plugin.show.settings.ProjectSettingsState"/>
|
||||
</extensions>
|
||||
|
||||
<actions>
|
||||
<action
|
||||
id="io.github.linwancen.plugin.show.ext.conf.ReLoadExtDocAction"
|
||||
class="io.github.linwancen.plugin.show.ext.conf.ReloadExtDocAction"
|
||||
text="🔄 // Reload External Comment">
|
||||
<add-to-group group-id="ToolsMenu"/>
|
||||
</action>
|
||||
<action
|
||||
id="io.github.linwancen.plugin.show.ext.conf.ResetExtDocAction"
|
||||
class="io.github.linwancen.plugin.show.ext.conf.ResetExtDocAction"
|
||||
text="🆑 // Clear External Comment">
|
||||
<add-to-group group-id="ToolsMenu"/>
|
||||
</action>
|
||||
<action
|
||||
id="io.github.linwancen.plugin.show.LineEndCopy"
|
||||
class="io.github.linwancen.plugin.show.LineEndCopy"
|
||||
text="// Copy With Line Comment">
|
||||
<add-to-group group-id="EditorPopupMenu" anchor="after"
|
||||
relative-to-action="CopyReference"/>
|
||||
</action>
|
||||
<action
|
||||
id="io.github.linwancen.plugin.show.CopyReferenceSimple"
|
||||
class="io.github.linwancen.plugin.show.CopyReferenceSimple"
|
||||
text="Copy Class.Method/File:Line">
|
||||
<add-to-group group-id="EditorPopupMenu" anchor="after"
|
||||
relative-to-action="CopyReference"/>
|
||||
</action>
|
||||
<action
|
||||
id="io.github.linwancen.plugin.show.LineEndAdd"
|
||||
class="io.github.linwancen.plugin.show.LineEndAdd"
|
||||
text="// Add Line Comment">
|
||||
<add-to-group group-id="ProjectViewPopupMenu" anchor="last"/>
|
||||
</action>
|
||||
</actions>
|
||||
<actions>
|
||||
<action
|
||||
id="io.github.linwancen.plugin.show.ext.conf.ReLoadExtDocAction"
|
||||
class="io.github.linwancen.plugin.show.ext.conf.ReloadExtDocAction"
|
||||
text="🔄 // Reload External Comment">
|
||||
<add-to-group group-id="ToolsMenu"/>
|
||||
</action>
|
||||
<action
|
||||
id="io.github.linwancen.plugin.show.ext.conf.ResetExtDocAction"
|
||||
class="io.github.linwancen.plugin.show.ext.conf.ResetExtDocAction"
|
||||
text="🆑 // Clear External Comment">
|
||||
<add-to-group group-id="ToolsMenu"/>
|
||||
</action>
|
||||
<action
|
||||
id="io.github.linwancen.plugin.show.LineEndCopy"
|
||||
class="io.github.linwancen.plugin.show.LineEndCopy"
|
||||
text="// Copy With Line Comment">
|
||||
<add-to-group group-id="EditorPopupMenu" anchor="after"
|
||||
relative-to-action="CopyReference"/>
|
||||
</action>
|
||||
<action
|
||||
id="io.github.linwancen.plugin.show.CopyReferenceSimple"
|
||||
class="io.github.linwancen.plugin.show.CopyReferenceSimple"
|
||||
text="Copy Class.Method/File:Line">
|
||||
<add-to-group group-id="EditorPopupMenu" anchor="after"
|
||||
relative-to-action="CopyReference"/>
|
||||
</action>
|
||||
<action
|
||||
id="io.github.linwancen.plugin.show.LineEndAdd"
|
||||
class="io.github.linwancen.plugin.show.LineEndAdd"
|
||||
text="// Add Line Comment">
|
||||
<add-to-group group-id="ProjectViewPopupMenu" anchor="last"/>
|
||||
</action>
|
||||
</actions>
|
||||
</idea-plugin>
|
||||
@@ -1,254 +1,263 @@
|
||||
<templateSet group="show-comment-doc">
|
||||
<template name="doc" value="/** $SELECTION$ */" description="/** one line */" toReformat="false" toShortenFQNames="true">
|
||||
<template name="doc" value="/** $SELECTION$ */" description="/** one line */" toReformat="false"
|
||||
toShortenFQNames="true">
|
||||
<context>
|
||||
<option name="COMPLETION" value="false" />
|
||||
<option name="ECMAScript6" value="true" />
|
||||
<option name="ES6_CLASS" value="false" />
|
||||
<option name="ES6_EXPRESSION" value="false" />
|
||||
<option name="ES6_STATEMENT" value="false" />
|
||||
<option name="GROOVY" value="true" />
|
||||
<option name="GROOVY_EXPRESSION" value="false" />
|
||||
<option name="GROOVY_STATEMENT" value="false" />
|
||||
<option name="JAVA_CODE" value="true" />
|
||||
<option name="JAVA_COMMENT" value="false" />
|
||||
<option name="JAVA_CONSUMER" value="false" />
|
||||
<option name="JAVA_ELSE_PLACE" value="false" />
|
||||
<option name="JAVA_EXPRESSION" value="false" />
|
||||
<option name="JAVA_SCRIPT" value="true" />
|
||||
<option name="JAVA_STATEMENT" value="false" />
|
||||
<option name="JAVA_STRING" value="false" />
|
||||
<option name="JSX_HTML" value="false" />
|
||||
<option name="JS_CLASS" value="false" />
|
||||
<option name="JS_DOT_PROPERTY_ACCESS" value="false" />
|
||||
<option name="JS_EXPRESSION" value="false" />
|
||||
<option name="JS_STATEMENT" value="false" />
|
||||
<option name="KOTLIN" value="true" />
|
||||
<option name="KOTLIN_CLASS" value="false" />
|
||||
<option name="KOTLIN_COMMENT" value="false" />
|
||||
<option name="KOTLIN_EXPRESSION" value="false" />
|
||||
<option name="KOTLIN_STATEMENT" value="false" />
|
||||
<option name="TS_CLASS" value="false" />
|
||||
<option name="TS_EXPRESSION" value="false" />
|
||||
<option name="TS_STATEMENT" value="false" />
|
||||
<option name="TypeScript" value="true" />
|
||||
<option name="COMPLETION" value="false"/>
|
||||
<option name="ECMAScript6" value="true"/>
|
||||
<option name="ES6_CLASS" value="false"/>
|
||||
<option name="ES6_EXPRESSION" value="false"/>
|
||||
<option name="ES6_STATEMENT" value="false"/>
|
||||
<option name="GROOVY" value="true"/>
|
||||
<option name="GROOVY_EXPRESSION" value="false"/>
|
||||
<option name="GROOVY_STATEMENT" value="false"/>
|
||||
<option name="JAVA_CODE" value="true"/>
|
||||
<option name="JAVA_COMMENT" value="false"/>
|
||||
<option name="JAVA_CONSUMER" value="false"/>
|
||||
<option name="JAVA_ELSE_PLACE" value="false"/>
|
||||
<option name="JAVA_EXPRESSION" value="false"/>
|
||||
<option name="JAVA_SCRIPT" value="true"/>
|
||||
<option name="JAVA_STATEMENT" value="false"/>
|
||||
<option name="JAVA_STRING" value="false"/>
|
||||
<option name="JSX_HTML" value="false"/>
|
||||
<option name="JS_CLASS" value="false"/>
|
||||
<option name="JS_DOT_PROPERTY_ACCESS" value="false"/>
|
||||
<option name="JS_EXPRESSION" value="false"/>
|
||||
<option name="JS_STATEMENT" value="false"/>
|
||||
<option name="KOTLIN" value="true"/>
|
||||
<option name="KOTLIN_CLASS" value="false"/>
|
||||
<option name="KOTLIN_COMMENT" value="false"/>
|
||||
<option name="KOTLIN_EXPRESSION" value="false"/>
|
||||
<option name="KOTLIN_STATEMENT" value="false"/>
|
||||
<option name="TS_CLASS" value="false"/>
|
||||
<option name="TS_EXPRESSION" value="false"/>
|
||||
<option name="TS_STATEMENT" value="false"/>
|
||||
<option name="TypeScript" value="true"/>
|
||||
</context>
|
||||
</template>
|
||||
<template name="docc" value="/** * $SELECTION$ */" description="/** multi line */" toReformat="false" toShortenFQNames="true">
|
||||
<template name="docc" value="/** * $SELECTION$ */" description="/** multi line */" toReformat="false"
|
||||
toShortenFQNames="true">
|
||||
<context>
|
||||
<option name="COMPLETION" value="false" />
|
||||
<option name="ECMAScript6" value="true" />
|
||||
<option name="ES6_CLASS" value="false" />
|
||||
<option name="ES6_EXPRESSION" value="false" />
|
||||
<option name="ES6_STATEMENT" value="false" />
|
||||
<option name="GROOVY" value="true" />
|
||||
<option name="GROOVY_EXPRESSION" value="false" />
|
||||
<option name="GROOVY_STATEMENT" value="false" />
|
||||
<option name="JAVA_CODE" value="true" />
|
||||
<option name="JAVA_COMMENT" value="false" />
|
||||
<option name="JAVA_CONSUMER" value="false" />
|
||||
<option name="JAVA_ELSE_PLACE" value="false" />
|
||||
<option name="JAVA_EXPRESSION" value="false" />
|
||||
<option name="JAVA_SCRIPT" value="true" />
|
||||
<option name="JAVA_STATEMENT" value="false" />
|
||||
<option name="JAVA_STRING" value="false" />
|
||||
<option name="JSX_HTML" value="false" />
|
||||
<option name="JS_CLASS" value="false" />
|
||||
<option name="JS_DOT_PROPERTY_ACCESS" value="false" />
|
||||
<option name="JS_EXPRESSION" value="false" />
|
||||
<option name="JS_STATEMENT" value="false" />
|
||||
<option name="KOTLIN" value="true" />
|
||||
<option name="KOTLIN_CLASS" value="false" />
|
||||
<option name="KOTLIN_COMMENT" value="false" />
|
||||
<option name="KOTLIN_EXPRESSION" value="false" />
|
||||
<option name="KOTLIN_STATEMENT" value="false" />
|
||||
<option name="TS_CLASS" value="false" />
|
||||
<option name="TS_EXPRESSION" value="false" />
|
||||
<option name="TS_STATEMENT" value="false" />
|
||||
<option name="TypeScript" value="true" />
|
||||
<option name="COMPLETION" value="false"/>
|
||||
<option name="ECMAScript6" value="true"/>
|
||||
<option name="ES6_CLASS" value="false"/>
|
||||
<option name="ES6_EXPRESSION" value="false"/>
|
||||
<option name="ES6_STATEMENT" value="false"/>
|
||||
<option name="GROOVY" value="true"/>
|
||||
<option name="GROOVY_EXPRESSION" value="false"/>
|
||||
<option name="GROOVY_STATEMENT" value="false"/>
|
||||
<option name="JAVA_CODE" value="true"/>
|
||||
<option name="JAVA_COMMENT" value="false"/>
|
||||
<option name="JAVA_CONSUMER" value="false"/>
|
||||
<option name="JAVA_ELSE_PLACE" value="false"/>
|
||||
<option name="JAVA_EXPRESSION" value="false"/>
|
||||
<option name="JAVA_SCRIPT" value="true"/>
|
||||
<option name="JAVA_STATEMENT" value="false"/>
|
||||
<option name="JAVA_STRING" value="false"/>
|
||||
<option name="JSX_HTML" value="false"/>
|
||||
<option name="JS_CLASS" value="false"/>
|
||||
<option name="JS_DOT_PROPERTY_ACCESS" value="false"/>
|
||||
<option name="JS_EXPRESSION" value="false"/>
|
||||
<option name="JS_STATEMENT" value="false"/>
|
||||
<option name="KOTLIN" value="true"/>
|
||||
<option name="KOTLIN_CLASS" value="false"/>
|
||||
<option name="KOTLIN_COMMENT" value="false"/>
|
||||
<option name="KOTLIN_EXPRESSION" value="false"/>
|
||||
<option name="KOTLIN_STATEMENT" value="false"/>
|
||||
<option name="TS_CLASS" value="false"/>
|
||||
<option name="TS_EXPRESSION" value="false"/>
|
||||
<option name="TS_STATEMENT" value="false"/>
|
||||
<option name="TypeScript" value="true"/>
|
||||
</context>
|
||||
</template>
|
||||
<template name="docb" value="/** * $SELECTION$ * <br> */" description="/** <br> */" toReformat="false" toShortenFQNames="true">
|
||||
<template name="docb" value="/** * $SELECTION$ * <br> */" description="/** <br> */"
|
||||
toReformat="false" toShortenFQNames="true">
|
||||
<context>
|
||||
<option name="COMPLETION" value="false" />
|
||||
<option name="ECMAScript6" value="true" />
|
||||
<option name="ES6_CLASS" value="false" />
|
||||
<option name="ES6_EXPRESSION" value="false" />
|
||||
<option name="ES6_STATEMENT" value="false" />
|
||||
<option name="GROOVY" value="true" />
|
||||
<option name="GROOVY_EXPRESSION" value="false" />
|
||||
<option name="GROOVY_STATEMENT" value="false" />
|
||||
<option name="JAVA_CODE" value="true" />
|
||||
<option name="JAVA_COMMENT" value="false" />
|
||||
<option name="JAVA_CONSUMER" value="false" />
|
||||
<option name="JAVA_ELSE_PLACE" value="false" />
|
||||
<option name="JAVA_EXPRESSION" value="false" />
|
||||
<option name="JAVA_SCRIPT" value="true" />
|
||||
<option name="JAVA_STATEMENT" value="false" />
|
||||
<option name="JAVA_STRING" value="false" />
|
||||
<option name="JSX_HTML" value="false" />
|
||||
<option name="JS_CLASS" value="false" />
|
||||
<option name="JS_DOT_PROPERTY_ACCESS" value="false" />
|
||||
<option name="JS_EXPRESSION" value="false" />
|
||||
<option name="JS_STATEMENT" value="false" />
|
||||
<option name="KOTLIN" value="true" />
|
||||
<option name="KOTLIN_CLASS" value="false" />
|
||||
<option name="KOTLIN_COMMENT" value="false" />
|
||||
<option name="KOTLIN_EXPRESSION" value="false" />
|
||||
<option name="KOTLIN_STATEMENT" value="false" />
|
||||
<option name="TS_CLASS" value="false" />
|
||||
<option name="TS_EXPRESSION" value="false" />
|
||||
<option name="TS_STATEMENT" value="false" />
|
||||
<option name="TypeScript" value="true" />
|
||||
<option name="COMPLETION" value="false"/>
|
||||
<option name="ECMAScript6" value="true"/>
|
||||
<option name="ES6_CLASS" value="false"/>
|
||||
<option name="ES6_EXPRESSION" value="false"/>
|
||||
<option name="ES6_STATEMENT" value="false"/>
|
||||
<option name="GROOVY" value="true"/>
|
||||
<option name="GROOVY_EXPRESSION" value="false"/>
|
||||
<option name="GROOVY_STATEMENT" value="false"/>
|
||||
<option name="JAVA_CODE" value="true"/>
|
||||
<option name="JAVA_COMMENT" value="false"/>
|
||||
<option name="JAVA_CONSUMER" value="false"/>
|
||||
<option name="JAVA_ELSE_PLACE" value="false"/>
|
||||
<option name="JAVA_EXPRESSION" value="false"/>
|
||||
<option name="JAVA_SCRIPT" value="true"/>
|
||||
<option name="JAVA_STATEMENT" value="false"/>
|
||||
<option name="JAVA_STRING" value="false"/>
|
||||
<option name="JSX_HTML" value="false"/>
|
||||
<option name="JS_CLASS" value="false"/>
|
||||
<option name="JS_DOT_PROPERTY_ACCESS" value="false"/>
|
||||
<option name="JS_EXPRESSION" value="false"/>
|
||||
<option name="JS_STATEMENT" value="false"/>
|
||||
<option name="KOTLIN" value="true"/>
|
||||
<option name="KOTLIN_CLASS" value="false"/>
|
||||
<option name="KOTLIN_COMMENT" value="false"/>
|
||||
<option name="KOTLIN_EXPRESSION" value="false"/>
|
||||
<option name="KOTLIN_STATEMENT" value="false"/>
|
||||
<option name="TS_CLASS" value="false"/>
|
||||
<option name="TS_EXPRESSION" value="false"/>
|
||||
<option name="TS_STATEMENT" value="false"/>
|
||||
<option name="TypeScript" value="true"/>
|
||||
</context>
|
||||
</template>
|
||||
<template name="docl" value="/** * $SELECTION$ * <ul> * <li> * </ul> */" description="/** <li> */" toReformat="false" toShortenFQNames="true">
|
||||
<template name="docl" value="/** * $SELECTION$ * <ul> * <li> * </ul> */"
|
||||
description="/** <li> */" toReformat="false" toShortenFQNames="true">
|
||||
<context>
|
||||
<option name="COMPLETION" value="false" />
|
||||
<option name="ECMAScript6" value="true" />
|
||||
<option name="ES6_CLASS" value="false" />
|
||||
<option name="ES6_EXPRESSION" value="false" />
|
||||
<option name="ES6_STATEMENT" value="false" />
|
||||
<option name="GROOVY" value="true" />
|
||||
<option name="GROOVY_EXPRESSION" value="false" />
|
||||
<option name="GROOVY_STATEMENT" value="false" />
|
||||
<option name="JAVA_CODE" value="true" />
|
||||
<option name="JAVA_COMMENT" value="false" />
|
||||
<option name="JAVA_CONSUMER" value="false" />
|
||||
<option name="JAVA_ELSE_PLACE" value="false" />
|
||||
<option name="JAVA_EXPRESSION" value="false" />
|
||||
<option name="JAVA_SCRIPT" value="true" />
|
||||
<option name="JAVA_STATEMENT" value="false" />
|
||||
<option name="JAVA_STRING" value="false" />
|
||||
<option name="JSX_HTML" value="false" />
|
||||
<option name="JS_CLASS" value="false" />
|
||||
<option name="JS_DOT_PROPERTY_ACCESS" value="false" />
|
||||
<option name="JS_EXPRESSION" value="false" />
|
||||
<option name="JS_STATEMENT" value="false" />
|
||||
<option name="KOTLIN" value="true" />
|
||||
<option name="KOTLIN_CLASS" value="false" />
|
||||
<option name="KOTLIN_COMMENT" value="false" />
|
||||
<option name="KOTLIN_EXPRESSION" value="false" />
|
||||
<option name="KOTLIN_STATEMENT" value="false" />
|
||||
<option name="TS_CLASS" value="false" />
|
||||
<option name="TS_EXPRESSION" value="false" />
|
||||
<option name="TS_STATEMENT" value="false" />
|
||||
<option name="TypeScript" value="true" />
|
||||
<option name="COMPLETION" value="false"/>
|
||||
<option name="ECMAScript6" value="true"/>
|
||||
<option name="ES6_CLASS" value="false"/>
|
||||
<option name="ES6_EXPRESSION" value="false"/>
|
||||
<option name="ES6_STATEMENT" value="false"/>
|
||||
<option name="GROOVY" value="true"/>
|
||||
<option name="GROOVY_EXPRESSION" value="false"/>
|
||||
<option name="GROOVY_STATEMENT" value="false"/>
|
||||
<option name="JAVA_CODE" value="true"/>
|
||||
<option name="JAVA_COMMENT" value="false"/>
|
||||
<option name="JAVA_CONSUMER" value="false"/>
|
||||
<option name="JAVA_ELSE_PLACE" value="false"/>
|
||||
<option name="JAVA_EXPRESSION" value="false"/>
|
||||
<option name="JAVA_SCRIPT" value="true"/>
|
||||
<option name="JAVA_STATEMENT" value="false"/>
|
||||
<option name="JAVA_STRING" value="false"/>
|
||||
<option name="JSX_HTML" value="false"/>
|
||||
<option name="JS_CLASS" value="false"/>
|
||||
<option name="JS_DOT_PROPERTY_ACCESS" value="false"/>
|
||||
<option name="JS_EXPRESSION" value="false"/>
|
||||
<option name="JS_STATEMENT" value="false"/>
|
||||
<option name="KOTLIN" value="true"/>
|
||||
<option name="KOTLIN_CLASS" value="false"/>
|
||||
<option name="KOTLIN_COMMENT" value="false"/>
|
||||
<option name="KOTLIN_EXPRESSION" value="false"/>
|
||||
<option name="KOTLIN_STATEMENT" value="false"/>
|
||||
<option name="TS_CLASS" value="false"/>
|
||||
<option name="TS_EXPRESSION" value="false"/>
|
||||
<option name="TS_STATEMENT" value="false"/>
|
||||
<option name="TypeScript" value="true"/>
|
||||
</context>
|
||||
</template>
|
||||
<template name="la" value="// language="$lang$"" description="// language=""" toReformat="true" toShortenFQNames="true">
|
||||
<variable name="lang" expression="" defaultValue="" alwaysStopAt="true" />
|
||||
<template name="la" value="// language="$lang$"" description="// language=""" toReformat="true"
|
||||
toShortenFQNames="true">
|
||||
<variable name="lang" expression="" defaultValue="" alwaysStopAt="true"/>
|
||||
<context>
|
||||
<option name="COMPLETION" value="false" />
|
||||
<option name="ECMAScript6" value="true" />
|
||||
<option name="ES6_CLASS" value="false" />
|
||||
<option name="ES6_EXPRESSION" value="false" />
|
||||
<option name="GROOVY" value="true" />
|
||||
<option name="GROOVY_EXPRESSION" value="false" />
|
||||
<option name="JAVA_CODE" value="true" />
|
||||
<option name="JAVA_COMMENT" value="false" />
|
||||
<option name="JAVA_CONSUMER" value="false" />
|
||||
<option name="JAVA_EXPRESSION" value="false" />
|
||||
<option name="JAVA_SCRIPT" value="true" />
|
||||
<option name="JAVA_STRING" value="false" />
|
||||
<option name="JSX_HTML" value="false" />
|
||||
<option name="JS_CLASS" value="false" />
|
||||
<option name="JS_DOT_PROPERTY_ACCESS" value="false" />
|
||||
<option name="JS_EXPRESSION" value="false" />
|
||||
<option name="KOTLIN" value="true" />
|
||||
<option name="KOTLIN_CLASS" value="false" />
|
||||
<option name="KOTLIN_COMMENT" value="false" />
|
||||
<option name="KOTLIN_EXPRESSION" value="false" />
|
||||
<option name="KOTLIN_TOPLEVEL" value="false" />
|
||||
<option name="TS_CLASS" value="false" />
|
||||
<option name="TS_EXPRESSION" value="false" />
|
||||
<option name="TypeScript" value="true" />
|
||||
<option name="COMPLETION" value="false"/>
|
||||
<option name="ECMAScript6" value="true"/>
|
||||
<option name="ES6_CLASS" value="false"/>
|
||||
<option name="ES6_EXPRESSION" value="false"/>
|
||||
<option name="GROOVY" value="true"/>
|
||||
<option name="GROOVY_EXPRESSION" value="false"/>
|
||||
<option name="JAVA_CODE" value="true"/>
|
||||
<option name="JAVA_COMMENT" value="false"/>
|
||||
<option name="JAVA_CONSUMER" value="false"/>
|
||||
<option name="JAVA_EXPRESSION" value="false"/>
|
||||
<option name="JAVA_SCRIPT" value="true"/>
|
||||
<option name="JAVA_STRING" value="false"/>
|
||||
<option name="JSX_HTML" value="false"/>
|
||||
<option name="JS_CLASS" value="false"/>
|
||||
<option name="JS_DOT_PROPERTY_ACCESS" value="false"/>
|
||||
<option name="JS_EXPRESSION" value="false"/>
|
||||
<option name="KOTLIN" value="true"/>
|
||||
<option name="KOTLIN_CLASS" value="false"/>
|
||||
<option name="KOTLIN_COMMENT" value="false"/>
|
||||
<option name="KOTLIN_EXPRESSION" value="false"/>
|
||||
<option name="KOTLIN_TOPLEVEL" value="false"/>
|
||||
<option name="TS_CLASS" value="false"/>
|
||||
<option name="TS_EXPRESSION" value="false"/>
|
||||
<option name="TypeScript" value="true"/>
|
||||
</context>
|
||||
</template>
|
||||
<template name="reg" value="// region $comment$" description="// region $comment$" toReformat="true" toShortenFQNames="true">
|
||||
<variable name="comment" expression="" defaultValue="" alwaysStopAt="true" />
|
||||
<template name="reg" value="// region $comment$" description="// region $comment$" toReformat="true"
|
||||
toShortenFQNames="true">
|
||||
<variable name="comment" expression="" defaultValue="" alwaysStopAt="true"/>
|
||||
<context>
|
||||
<option name="COMPLETION" value="false" />
|
||||
<option name="ECMAScript6" value="true" />
|
||||
<option name="ES6_CLASS" value="false" />
|
||||
<option name="ES6_EXPRESSION" value="false" />
|
||||
<option name="GROOVY" value="true" />
|
||||
<option name="GROOVY_EXPRESSION" value="false" />
|
||||
<option name="JAVA_CODE" value="true" />
|
||||
<option name="JAVA_COMMENT" value="false" />
|
||||
<option name="JAVA_CONSUMER" value="false" />
|
||||
<option name="JAVA_EXPRESSION" value="false" />
|
||||
<option name="JAVA_SCRIPT" value="true" />
|
||||
<option name="JAVA_STRING" value="false" />
|
||||
<option name="JSX_HTML" value="false" />
|
||||
<option name="JS_CLASS" value="false" />
|
||||
<option name="JS_DOT_PROPERTY_ACCESS" value="false" />
|
||||
<option name="JS_EXPRESSION" value="false" />
|
||||
<option name="KOTLIN" value="true" />
|
||||
<option name="KOTLIN_CLASS" value="false" />
|
||||
<option name="KOTLIN_COMMENT" value="false" />
|
||||
<option name="KOTLIN_EXPRESSION" value="false" />
|
||||
<option name="KOTLIN_TOPLEVEL" value="false" />
|
||||
<option name="TS_CLASS" value="false" />
|
||||
<option name="TS_EXPRESSION" value="false" />
|
||||
<option name="TypeScript" value="true" />
|
||||
<option name="COMPLETION" value="false"/>
|
||||
<option name="ECMAScript6" value="true"/>
|
||||
<option name="ES6_CLASS" value="false"/>
|
||||
<option name="ES6_EXPRESSION" value="false"/>
|
||||
<option name="GROOVY" value="true"/>
|
||||
<option name="GROOVY_EXPRESSION" value="false"/>
|
||||
<option name="JAVA_CODE" value="true"/>
|
||||
<option name="JAVA_COMMENT" value="false"/>
|
||||
<option name="JAVA_CONSUMER" value="false"/>
|
||||
<option name="JAVA_EXPRESSION" value="false"/>
|
||||
<option name="JAVA_SCRIPT" value="true"/>
|
||||
<option name="JAVA_STRING" value="false"/>
|
||||
<option name="JSX_HTML" value="false"/>
|
||||
<option name="JS_CLASS" value="false"/>
|
||||
<option name="JS_DOT_PROPERTY_ACCESS" value="false"/>
|
||||
<option name="JS_EXPRESSION" value="false"/>
|
||||
<option name="KOTLIN" value="true"/>
|
||||
<option name="KOTLIN_CLASS" value="false"/>
|
||||
<option name="KOTLIN_COMMENT" value="false"/>
|
||||
<option name="KOTLIN_EXPRESSION" value="false"/>
|
||||
<option name="KOTLIN_TOPLEVEL" value="false"/>
|
||||
<option name="TS_CLASS" value="false"/>
|
||||
<option name="TS_EXPRESSION" value="false"/>
|
||||
<option name="TypeScript" value="true"/>
|
||||
</context>
|
||||
</template>
|
||||
<template name="end" value="// endregion $comment$" description="// endregion $comment$" toReformat="true" toShortenFQNames="true">
|
||||
<variable name="comment" expression="" defaultValue="" alwaysStopAt="true" />
|
||||
<template name="end" value="// endregion $comment$" description="// endregion $comment$" toReformat="true"
|
||||
toShortenFQNames="true">
|
||||
<variable name="comment" expression="" defaultValue="" alwaysStopAt="true"/>
|
||||
<context>
|
||||
<option name="COMPLETION" value="false" />
|
||||
<option name="ECMAScript6" value="true" />
|
||||
<option name="ES6_CLASS" value="false" />
|
||||
<option name="ES6_EXPRESSION" value="false" />
|
||||
<option name="GROOVY" value="true" />
|
||||
<option name="GROOVY_EXPRESSION" value="false" />
|
||||
<option name="JAVA_CODE" value="true" />
|
||||
<option name="JAVA_COMMENT" value="false" />
|
||||
<option name="JAVA_CONSUMER" value="false" />
|
||||
<option name="JAVA_EXPRESSION" value="false" />
|
||||
<option name="JAVA_SCRIPT" value="true" />
|
||||
<option name="JAVA_STRING" value="false" />
|
||||
<option name="JSX_HTML" value="false" />
|
||||
<option name="JS_CLASS" value="false" />
|
||||
<option name="JS_DOT_PROPERTY_ACCESS" value="false" />
|
||||
<option name="JS_EXPRESSION" value="false" />
|
||||
<option name="KOTLIN" value="true" />
|
||||
<option name="KOTLIN_CLASS" value="false" />
|
||||
<option name="KOTLIN_COMMENT" value="false" />
|
||||
<option name="KOTLIN_EXPRESSION" value="false" />
|
||||
<option name="KOTLIN_TOPLEVEL" value="false" />
|
||||
<option name="TS_CLASS" value="false" />
|
||||
<option name="TS_EXPRESSION" value="false" />
|
||||
<option name="TypeScript" value="true" />
|
||||
<option name="COMPLETION" value="false"/>
|
||||
<option name="ECMAScript6" value="true"/>
|
||||
<option name="ES6_CLASS" value="false"/>
|
||||
<option name="ES6_EXPRESSION" value="false"/>
|
||||
<option name="GROOVY" value="true"/>
|
||||
<option name="GROOVY_EXPRESSION" value="false"/>
|
||||
<option name="JAVA_CODE" value="true"/>
|
||||
<option name="JAVA_COMMENT" value="false"/>
|
||||
<option name="JAVA_CONSUMER" value="false"/>
|
||||
<option name="JAVA_EXPRESSION" value="false"/>
|
||||
<option name="JAVA_SCRIPT" value="true"/>
|
||||
<option name="JAVA_STRING" value="false"/>
|
||||
<option name="JSX_HTML" value="false"/>
|
||||
<option name="JS_CLASS" value="false"/>
|
||||
<option name="JS_DOT_PROPERTY_ACCESS" value="false"/>
|
||||
<option name="JS_EXPRESSION" value="false"/>
|
||||
<option name="KOTLIN" value="true"/>
|
||||
<option name="KOTLIN_CLASS" value="false"/>
|
||||
<option name="KOTLIN_COMMENT" value="false"/>
|
||||
<option name="KOTLIN_EXPRESSION" value="false"/>
|
||||
<option name="KOTLIN_TOPLEVEL" value="false"/>
|
||||
<option name="TS_CLASS" value="false"/>
|
||||
<option name="TS_EXPRESSION" value="false"/>
|
||||
<option name="TypeScript" value="true"/>
|
||||
</context>
|
||||
</template>
|
||||
<template name="hr" value="/* ******************* $text$ ******************* */" description="/* ******************* $comm$ ******************* */ 20*" toReformat="false" toShortenFQNames="true">
|
||||
<variable name="text" expression="" defaultValue="" alwaysStopAt="true" />
|
||||
<template name="hr" value="/* ******************* $text$ ******************* */"
|
||||
description="/* ******************* $comm$ ******************* */ 20*" toReformat="false"
|
||||
toShortenFQNames="true">
|
||||
<variable name="text" expression="" defaultValue="" alwaysStopAt="true"/>
|
||||
<context>
|
||||
<option name="COMPLETION" value="false" />
|
||||
<option name="ECMAScript6" value="true" />
|
||||
<option name="ES6_CLASS" value="false" />
|
||||
<option name="ES6_EXPRESSION" value="false" />
|
||||
<option name="GROOVY" value="true" />
|
||||
<option name="GROOVY_EXPRESSION" value="false" />
|
||||
<option name="JAVA_CODE" value="true" />
|
||||
<option name="JAVA_COMMENT" value="false" />
|
||||
<option name="JAVA_CONSUMER" value="false" />
|
||||
<option name="JAVA_EXPRESSION" value="false" />
|
||||
<option name="JAVA_SCRIPT" value="true" />
|
||||
<option name="JAVA_STRING" value="false" />
|
||||
<option name="JSX_HTML" value="false" />
|
||||
<option name="JS_CLASS" value="false" />
|
||||
<option name="JS_DOT_PROPERTY_ACCESS" value="false" />
|
||||
<option name="JS_EXPRESSION" value="false" />
|
||||
<option name="KOTLIN" value="true" />
|
||||
<option name="KOTLIN_CLASS" value="false" />
|
||||
<option name="KOTLIN_COMMENT" value="false" />
|
||||
<option name="KOTLIN_EXPRESSION" value="false" />
|
||||
<option name="KOTLIN_TOPLEVEL" value="false" />
|
||||
<option name="TS_CLASS" value="false" />
|
||||
<option name="TS_EXPRESSION" value="false" />
|
||||
<option name="TypeScript" value="true" />
|
||||
<option name="COMPLETION" value="false"/>
|
||||
<option name="ECMAScript6" value="true"/>
|
||||
<option name="ES6_CLASS" value="false"/>
|
||||
<option name="ES6_EXPRESSION" value="false"/>
|
||||
<option name="GROOVY" value="true"/>
|
||||
<option name="GROOVY_EXPRESSION" value="false"/>
|
||||
<option name="JAVA_CODE" value="true"/>
|
||||
<option name="JAVA_COMMENT" value="false"/>
|
||||
<option name="JAVA_CONSUMER" value="false"/>
|
||||
<option name="JAVA_EXPRESSION" value="false"/>
|
||||
<option name="JAVA_SCRIPT" value="true"/>
|
||||
<option name="JAVA_STRING" value="false"/>
|
||||
<option name="JSX_HTML" value="false"/>
|
||||
<option name="JS_CLASS" value="false"/>
|
||||
<option name="JS_DOT_PROPERTY_ACCESS" value="false"/>
|
||||
<option name="JS_EXPRESSION" value="false"/>
|
||||
<option name="KOTLIN" value="true"/>
|
||||
<option name="KOTLIN_CLASS" value="false"/>
|
||||
<option name="KOTLIN_COMMENT" value="false"/>
|
||||
<option name="KOTLIN_EXPRESSION" value="false"/>
|
||||
<option name="KOTLIN_TOPLEVEL" value="false"/>
|
||||
<option name="TS_CLASS" value="false"/>
|
||||
<option name="TS_EXPRESSION" value="false"/>
|
||||
<option name="TypeScript" value="true"/>
|
||||
</context>
|
||||
</template>
|
||||
</templateSet>
|
||||
@@ -1,12 +1,13 @@
|
||||
<templateSet group="show-comment-xml">
|
||||
<template name="doc" value=" <!-- $SELECTION$ -->" description="<!-- -->" toReformat="true" toShortenFQNames="true">
|
||||
<template name="doc" value=" <!-- $SELECTION$ -->" description="<!-- -->" toReformat="true"
|
||||
toShortenFQNames="true">
|
||||
<context>
|
||||
<option name="HTML" value="true" />
|
||||
<option name="HTML_TEXT" value="false" />
|
||||
<option name="JSP" value="true" />
|
||||
<option name="MAVEN" value="true" />
|
||||
<option name="XML" value="true" />
|
||||
<option name="XSL_TEXT" value="false" />
|
||||
<option name="HTML" value="true"/>
|
||||
<option name="HTML_TEXT" value="false"/>
|
||||
<option name="JSP" value="true"/>
|
||||
<option name="MAVEN" value="true"/>
|
||||
<option name="XML" value="true"/>
|
||||
<option name="XSL_TEXT" value="false"/>
|
||||
</context>
|
||||
</template>
|
||||
</templateSet>
|
||||
@@ -1,25 +1,25 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Title</title>
|
||||
<meta charset="UTF-8">
|
||||
<title>Title</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
</body>
|
||||
<script type="javascript">
|
||||
lineBlock(isNotDoc)
|
||||
lineBlock(docVal)
|
||||
lineBlock(isNotDoc)
|
||||
lineBlock(docVal)
|
||||
|
||||
// isNotDoc
|
||||
const isNotDoc = ""
|
||||
// isNotDoc
|
||||
const isNotDoc = ""
|
||||
|
||||
/** docVal */
|
||||
const docVal = ""
|
||||
/** docVal */
|
||||
const docVal = ""
|
||||
|
||||
/*** lineBlock ***/
|
||||
function lineBlock(t) {
|
||||
return t
|
||||
}
|
||||
/*** lineBlock ***/
|
||||
function lineBlock(t) {
|
||||
return t
|
||||
}
|
||||
</script>
|
||||
</html>
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
lineBlock(isNotDoc)
|
||||
lineBlock(docVal)
|
||||
block()
|
||||
@@ -11,7 +10,7 @@ const docVal = ""
|
||||
|
||||
/*** lineBlock ***/
|
||||
function lineBlock(t) {
|
||||
return t
|
||||
return t
|
||||
}
|
||||
|
||||
/*****
|
||||
@@ -19,5 +18,5 @@ function lineBlock(t) {
|
||||
***** 2
|
||||
*****/
|
||||
function block(t) {
|
||||
return t
|
||||
return t
|
||||
}
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
obj.isA(obj.getB())
|
||||
obj.setA(obj.getB())
|
||||
obj.setB(obj.a)
|
||||
@@ -15,29 +14,29 @@ let b = obj
|
||||
|
||||
/** obj1 */
|
||||
let obj = {
|
||||
/** a */
|
||||
"a":"A",
|
||||
/** b */
|
||||
"b":"B",
|
||||
/** sub */
|
||||
"sub":{
|
||||
/** subKey */
|
||||
"subKey":"subVal"
|
||||
},
|
||||
/** isA */
|
||||
isA: function (t) {
|
||||
return t
|
||||
},
|
||||
/** setA */
|
||||
setA: function (t) {
|
||||
return t
|
||||
},
|
||||
/** getB */
|
||||
getB: function (t) {
|
||||
return t
|
||||
},
|
||||
/** setB */
|
||||
setB: function (t) {
|
||||
return t
|
||||
},
|
||||
/** a */
|
||||
"a": "A",
|
||||
/** b */
|
||||
"b": "B",
|
||||
/** sub */
|
||||
"sub": {
|
||||
/** subKey */
|
||||
"subKey": "subVal"
|
||||
},
|
||||
/** isA */
|
||||
isA: function (t) {
|
||||
return t
|
||||
},
|
||||
/** setA */
|
||||
setA: function (t) {
|
||||
return t
|
||||
},
|
||||
/** getB */
|
||||
getB: function (t) {
|
||||
return t
|
||||
},
|
||||
/** setB */
|
||||
setB: function (t) {
|
||||
return t
|
||||
},
|
||||
}
|
||||
@@ -13,6 +13,7 @@ class Type:
|
||||
# Type init
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
# field1
|
||||
field = ""
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ package io.github.linwancen.plugin.show.demo.java;
|
||||
|
||||
/**
|
||||
* InDoc
|
||||
*
|
||||
* <p>
|
||||
* {@link InDoc}
|
||||
* {@link InDoc#field}
|
||||
* {@link InDoc#method1}
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
{
|
||||
"nestedClass":
|
||||
{
|
||||
"nestedClass2": {
|
||||
"a": ""
|
||||
}
|
||||
"nestedClass": {
|
||||
"nestedClass2": {
|
||||
"a": ""
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1 +1,3 @@
|
||||
select * from NewTable where Column1 is not null ;
|
||||
select *
|
||||
from NewTable
|
||||
where Column1 is not null;
|
||||
Reference in New Issue
Block a user