feat(HtmlLangDoc): support HTML | 支持 HTML (VUE -> HTML -> XML)
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
package io.github.linwancen.plugin.show.lang;
|
||||
|
||||
import com.intellij.lang.html.HTMLLanguage;
|
||||
import io.github.linwancen.plugin.show.bean.LineInfo;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class HtmlLangDoc extends JsLangDoc {
|
||||
|
||||
static {
|
||||
LANG_DOC_MAP.put(HTMLLanguage.INSTANCE.getID(), new HtmlLangDoc());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean show(@NotNull LineInfo info) {
|
||||
return info.appSettings.showLineEndCommentJs;
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package io.github.linwancen.plugin.show.lang;
|
||||
|
||||
import com.intellij.json.JsonLanguage;
|
||||
import com.intellij.json.psi.JsonArray;
|
||||
import com.intellij.json.psi.JsonObject;
|
||||
import com.intellij.json.psi.JsonProperty;
|
||||
@@ -11,6 +12,7 @@ import com.intellij.psi.PsiReference;
|
||||
import com.intellij.psi.search.FilenameIndex;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import io.github.linwancen.plugin.show.bean.LineInfo;
|
||||
import io.github.linwancen.plugin.show.bean.SettingsInfo;
|
||||
import io.github.linwancen.plugin.show.ext.GetFromDocMap;
|
||||
import io.github.linwancen.plugin.show.ext.conf.ConfCache;
|
||||
import io.github.linwancen.plugin.show.ext.conf.ConfCacheGetUtils;
|
||||
@@ -27,7 +29,9 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public class JsonLangDoc extends BaseLangDoc {
|
||||
|
||||
public static final JsonLangDoc INSTANCE = new JsonLangDoc();
|
||||
static {
|
||||
LANG_DOC_MAP.put(JsonLanguage.INSTANCE.getID(), new JsonLangDoc());
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull List<Class<? extends PsiElement>> getRefClass() {
|
||||
@@ -126,4 +130,10 @@ public class JsonLangDoc extends BaseLangDoc {
|
||||
@NotNull SortedMap<String, Map<String, List<String>>> sortedMap = ConfCacheGetUtils.filterPath(fileMap, path);
|
||||
return GetFromDocMap.get(sortedMap, jsonValue);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
protected <T extends SettingsInfo> String resolveDocPrint(@NotNull T info, @NotNull PsiElement resolve) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
package io.github.linwancen.plugin.show.lang.base;
|
||||
|
||||
import com.intellij.ide.projectView.ProjectViewNode;
|
||||
import com.intellij.json.JsonLanguage;
|
||||
import com.intellij.lang.Language;
|
||||
import com.intellij.openapi.editor.EditorLinePainter;
|
||||
import com.intellij.openapi.editor.LineExtensionInfo;
|
||||
import com.intellij.openapi.project.Project;
|
||||
@@ -14,7 +12,6 @@ import com.intellij.psi.PsiManager;
|
||||
import com.intellij.psi.PsiReference;
|
||||
import io.github.linwancen.plugin.show.bean.LineInfo;
|
||||
import io.github.linwancen.plugin.show.bean.SettingsInfo;
|
||||
import io.github.linwancen.plugin.show.lang.JsonLangDoc;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -60,12 +57,12 @@ public abstract class BaseLangDoc extends EditorLinePainter {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@NotNull Language language = PsiElementTo.language(element);
|
||||
BaseLangDoc lineEnd = LANG_DOC_MAP.get(language.getID());
|
||||
if (lineEnd != null && lineEnd.show(info)) {
|
||||
@Nullable BaseLangDoc lineEnd = PsiElementTo.lineEnd(element);
|
||||
if (lineEnd == null) {
|
||||
return null;
|
||||
}
|
||||
if (lineEnd.show(info)) {
|
||||
return lineEnd.findRefDoc(info, viewProvider, element);
|
||||
} else if (language == JsonLanguage.INSTANCE && JsonLangDoc.INSTANCE.show(info)) {
|
||||
return JsonLangDoc.INSTANCE.findRefDoc(info, viewProvider, element);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -161,8 +158,7 @@ public abstract class BaseLangDoc extends EditorLinePainter {
|
||||
// ignore
|
||||
}
|
||||
// support like java <-> kotlin
|
||||
@NotNull Language language = PsiElementTo.language(psiElement);
|
||||
BaseLangDoc lineEnd = LANG_DOC_MAP.get(language.getID());
|
||||
@Nullable BaseLangDoc lineEnd = PsiElementTo.lineEnd(psiElement);
|
||||
if (lineEnd == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -25,12 +25,18 @@ public class PsiElementTo {
|
||||
return PsiManager.getInstance(resolve.getProject()).findViewProvider(resolveFile);
|
||||
}
|
||||
|
||||
public static @NotNull Language language(@NotNull PsiElement element) {
|
||||
@NotNull Language lang = element.getLanguage();
|
||||
@Nullable Language base = lang.getBaseLanguage();
|
||||
if (base != null) {
|
||||
return base;
|
||||
@Nullable
|
||||
public static BaseLangDoc lineEnd(@NotNull PsiElement element) {
|
||||
@Nullable Language language = element.getLanguage();
|
||||
while (true) {
|
||||
@Nullable BaseLangDoc lineEnd = BaseLangDoc.LANG_DOC_MAP.get(language.getID());
|
||||
if (lineEnd != null) {
|
||||
return lineEnd;
|
||||
}
|
||||
language = language.getBaseLanguage();
|
||||
if (language == null) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return lang;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<idea-plugin>
|
||||
<extensions defaultExtensionNs="com.intellij">
|
||||
<editor.linePainter implementation="io.github.linwancen.plugin.show.lang.JsLangDoc"/>
|
||||
<editor.linePainter implementation="io.github.linwancen.plugin.show.lang.HtmlLangDoc"/>
|
||||
</extensions>
|
||||
</idea-plugin>
|
||||
5
src/main/resources/META-INF/json.xml
Normal file
5
src/main/resources/META-INF/json.xml
Normal file
@@ -0,0 +1,5 @@
|
||||
<idea-plugin>
|
||||
<extensions defaultExtensionNs="com.intellij">
|
||||
<editor.linePainter implementation="io.github.linwancen.plugin.show.lang.JsonLangDoc"/>
|
||||
</extensions>
|
||||
</idea-plugin>
|
||||
@@ -137,6 +137,7 @@ Show doc comment in the Project view Tree, line End, json, other
|
||||
<depends optional="true" config-file="ruby.xml">com.intellij.modules.ruby</depends>
|
||||
<depends optional="true" config-file="c.xml">com.intellij.modules.clion</depends>
|
||||
<depends optional="true" config-file="swift.xml">com.intellij.modules.swift.lang</depends>
|
||||
<depends optional="true" config-file="json.xml">com.intellij.modules.json</depends>
|
||||
<depends optional="true" config-file="yaml.xml">org.jetbrains.plugins.yaml</depends>
|
||||
<!--<depends optional="true" config-file="cs.xml">com.intellij.modules.rider</depends>-->
|
||||
|
||||
|
||||
Reference in New Issue
Block a user