fix(PhpLangDoc): PHP file tree comment
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
package io.github.linwancen.plugin.show.lang;
|
||||
|
||||
import com.intellij.ide.projectView.ProjectViewNode;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.PsiComment;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.jetbrains.php.lang.PhpLanguage;
|
||||
@@ -33,6 +36,26 @@ public class PhpLangDoc extends BaseTagLangDoc<PhpDocComment> {
|
||||
return info.appSettings.showLineEndCommentPhp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable <T extends SettingsInfo> String treeDoc(@NotNull T info, @NotNull ProjectViewNode<?> node,
|
||||
@NotNull Project project) {
|
||||
Object value = node.getValue();
|
||||
if (value instanceof PsiElement) {
|
||||
@NotNull PsiElement psiElement = (PsiElement) value;
|
||||
if (psiElement.getLanguage() == PhpLanguage.INSTANCE) {
|
||||
@NotNull PsiElement[] children = psiElement.getChildren();
|
||||
for (PsiElement child : children) {
|
||||
@Nullable PsiComment comment = PsiTreeUtil.getChildOfType(child, PsiComment.class);
|
||||
if (comment != null) {
|
||||
String text = comment.getText();
|
||||
return DocFilter.cutDoc(text, info, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected <T extends SettingsInfo> boolean parseBaseComment(@NotNull T info) {
|
||||
return info.appSettings.showLineEndCommentPhpBase;
|
||||
|
||||
@@ -67,7 +67,8 @@ public class ResolveDoc {
|
||||
if (document == null) {
|
||||
return null;
|
||||
}
|
||||
@Nullable PsiElement psiElement = PsiTreeUtil.findChildOfType(resolve, PsiComment.class);
|
||||
// Do not use findChildOfType() because will find any comment at project view tree
|
||||
@Nullable PsiElement psiElement = PsiTreeUtil.getChildOfType(resolve, PsiComment.class);
|
||||
if (psiElement == null) {
|
||||
psiElement = Prev.prevCompactElement(info, resolve, document);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user