feat(YamlLangDoc): support YAML | 支持 YAML

This commit is contained in:
林万程
2024-03-12 19:07:04 +08:00
parent e4dee1d768
commit fab33e921b
8 changed files with 65 additions and 7 deletions

View File

@@ -15,6 +15,7 @@ Show doc comment in the Project view Tree, line End, json, other
<li>Java, Kotlin, Groovy, Scala <li>Java, Kotlin, Groovy, Scala
<li>C/C++/OC, Python, Go, Rust, Ruby <li>C/C++/OC, Python, Go, Rust, Ruby
<li>JS/TS, PHP, SQL <li>JS/TS, PHP, SQL
<li>YAML/yml
</ul> </ul>
<h4>English Note</h4> <h4>English Note</h4>

View File

@@ -30,6 +30,7 @@ intellij {
// see https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html#intellij-extension-plugins // see https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html#intellij-extension-plugins
plugins = [ plugins = [
'PsiViewer:201.6251.22-EAP-SNAPSHOT.3', // only for runIde when dev 'PsiViewer:201.6251.22-EAP-SNAPSHOT.3', // only for runIde when dev
'org.jetbrains.plugins.yaml',
'Pythonid:201.6668.121', 'Pythonid:201.6668.121',
'org.rust.lang:0.3.131.3366-201', 'org.rust.lang:0.3.131.3366-201',
'org.toml.lang:0.2.131.3366-201', 'org.toml.lang:0.2.131.3366-201',

View File

@@ -0,0 +1,35 @@
package io.github.linwancen.plugin.show.lang;
import com.intellij.psi.PsiElement;
import io.github.linwancen.plugin.show.bean.LineInfo;
import io.github.linwancen.plugin.show.bean.SettingsInfo;
import io.github.linwancen.plugin.show.lang.base.BaseLangDoc;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.yaml.YAMLLanguage;
import org.jetbrains.yaml.psi.YAMLKeyValue;
import java.util.List;
public class YamlLangDoc extends BaseLangDoc {
static {
LANG_DOC_MAP.put(YAMLLanguage.INSTANCE.getID(), new YamlLangDoc());
}
@Override
public @NotNull List<Class<? extends PsiElement>> getRefClass() {
return List.of(YAMLKeyValue.class);
}
@Override
public boolean show(@NotNull LineInfo info) {
return info.appSettings.showLineEndCommentYaml;
}
@Nullable
@Override
protected <T extends SettingsInfo> String resolveDocPrint(@NotNull T info, @NotNull PsiElement resolve) {
return null;
}
}

View File

@@ -29,10 +29,10 @@ public class AppSettingsComponent {
private final JBCheckBox showLineEndCommentScalaBase = new JBCheckBox("// Scala "); private final JBCheckBox showLineEndCommentScalaBase = new JBCheckBox("// Scala ");
private final JBCheckBox showLineEndCommentGroovy = new JBCheckBox(" Groovy "); private final JBCheckBox showLineEndCommentGroovy = new JBCheckBox(" Groovy ");
private final JBCheckBox showLineEndCommentGroovyBase = new JBCheckBox("// Groovy "); private final JBCheckBox showLineEndCommentGroovyBase = new JBCheckBox("// Groovy ");
private final JBCheckBox showLineEndCommentJs = new JBCheckBox(" js "); private final JBCheckBox showLineEndCommentJs = new JBCheckBox(" JS ");
private final JBCheckBox showLineEndCommentJsBase = new JBCheckBox("// js "); private final JBCheckBox showLineEndCommentJsBase = new JBCheckBox("// JS ");
private final JBCheckBox showLineEndCommentPhp = new JBCheckBox(" php "); private final JBCheckBox showLineEndCommentPhp = new JBCheckBox(" PHP ");
private final JBCheckBox showLineEndCommentPhpBase = new JBCheckBox("// php "); private final JBCheckBox showLineEndCommentPhpBase = new JBCheckBox("// PHP ");
private final JBCheckBox showLineEndCommentPy = new JBCheckBox(" Python "); private final JBCheckBox showLineEndCommentPy = new JBCheckBox(" Python ");
private final JBCheckBox showLineEndCommentPyBase = new JBCheckBox("# Python "); private final JBCheckBox showLineEndCommentPyBase = new JBCheckBox("# Python ");
private final JBCheckBox showLineEndCommentGo = new JBCheckBox(" Go "); private final JBCheckBox showLineEndCommentGo = new JBCheckBox(" Go ");
@@ -41,8 +41,9 @@ public class AppSettingsComponent {
private final JBCheckBox showLineEndCommentRubyBase = new JBCheckBox("// Ruby "); private final JBCheckBox showLineEndCommentRubyBase = new JBCheckBox("// Ruby ");
private final JBCheckBox showLineEndCommentCBase = new JBCheckBox("// C "); private final JBCheckBox showLineEndCommentCBase = new JBCheckBox("// C ");
private final JBCheckBox showLineEndCommentSwiftBase = new JBCheckBox("// Swift "); private final JBCheckBox showLineEndCommentSwiftBase = new JBCheckBox("// Swift ");
private final JBCheckBox showLineEndCommentSql = new JBCheckBox(" sql "); private final JBCheckBox showLineEndCommentSql = new JBCheckBox(" SQL ");
private final JBCheckBox showLineEndCommentJson = new JBCheckBox(" json "); private final JBCheckBox showLineEndCommentJson = new JBCheckBox(" JSON ");
private final JBCheckBox showLineEndCommentYaml = new JBCheckBox(" YAML ");
private final JBTextField lineTags = new JBTextField(); private final JBTextField lineTags = new JBTextField();
private final JBCheckBox getToSet = new JBCheckBox("get --> set "); private final JBCheckBox getToSet = new JBCheckBox("get --> set ");
private final JBCheckBox fromNew = new JBCheckBox("java new "); private final JBCheckBox fromNew = new JBCheckBox("java new ");
@@ -90,7 +91,8 @@ public class AppSettingsComponent {
showLineEndCommentGo, showLineEndCommentGo,
showLineEndCommentSql, showLineEndCommentSql,
showLineEndCommentJson showLineEndCommentJson,
showLineEndCommentYaml
), 1) ), 1)
.addComponent(JPanelFactory.of( .addComponent(JPanelFactory.of(
showLineEndCommentJsBase, showLineEndCommentJsBase,
@@ -359,6 +361,14 @@ public class AppSettingsComponent {
showLineEndCommentJson.setSelected(newStatus); showLineEndCommentJson.setSelected(newStatus);
} }
public boolean getShowLineEndCommentYaml() {
return showLineEndCommentYaml.isSelected();
}
public void setShowLineEndCommentYaml(boolean newStatus) {
showLineEndCommentYaml.setSelected(newStatus);
}
// endregion line end // endregion line end
@NotNull @NotNull

View File

@@ -63,6 +63,7 @@ public class AppSettingsConfigurable implements Configurable {
modified |= mySettingsComponent.getShowLineEndCommentSwiftBase() != settings.showLineEndCommentSwiftBase; modified |= mySettingsComponent.getShowLineEndCommentSwiftBase() != settings.showLineEndCommentSwiftBase;
modified |= mySettingsComponent.getShowLineEndCommentSql() != settings.showLineEndCommentSql; modified |= mySettingsComponent.getShowLineEndCommentSql() != settings.showLineEndCommentSql;
modified |= mySettingsComponent.getShowLineEndCommentJson() != settings.showLineEndCommentJson; modified |= mySettingsComponent.getShowLineEndCommentJson() != settings.showLineEndCommentJson;
modified |= mySettingsComponent.getShowLineEndCommentYaml() != settings.showLineEndCommentYaml;
modified |= !mySettingsComponent.getTreeTags().equals(String.join("|", settings.treeTags)); modified |= !mySettingsComponent.getTreeTags().equals(String.join("|", settings.treeTags));
modified |= !mySettingsComponent.getLineTags().equals(String.join("|", settings.lineTags)); modified |= !mySettingsComponent.getLineTags().equals(String.join("|", settings.lineTags));
@@ -112,6 +113,7 @@ public class AppSettingsConfigurable implements Configurable {
settings.showLineEndCommentSwiftBase = mySettingsComponent.getShowLineEndCommentSwiftBase(); settings.showLineEndCommentSwiftBase = mySettingsComponent.getShowLineEndCommentSwiftBase();
settings.showLineEndCommentSql = mySettingsComponent.getShowLineEndCommentSql(); settings.showLineEndCommentSql = mySettingsComponent.getShowLineEndCommentSql();
settings.showLineEndCommentJson = mySettingsComponent.getShowLineEndCommentJson(); settings.showLineEndCommentJson = mySettingsComponent.getShowLineEndCommentJson();
settings.showLineEndCommentYaml = mySettingsComponent.getShowLineEndCommentYaml();
settings.treeTags = Splitter.on('|').splitToList(mySettingsComponent.getTreeTags()).toArray(new String[0]); settings.treeTags = Splitter.on('|').splitToList(mySettingsComponent.getTreeTags()).toArray(new String[0]);
settings.lineTags = Splitter.on('|').splitToList(mySettingsComponent.getLineTags()).toArray(new String[0]); settings.lineTags = Splitter.on('|').splitToList(mySettingsComponent.getLineTags()).toArray(new String[0]);
@@ -164,6 +166,7 @@ public class AppSettingsConfigurable implements Configurable {
mySettingsComponent.setShowLineEndCommentSwiftBase(settings.showLineEndCommentSwiftBase); mySettingsComponent.setShowLineEndCommentSwiftBase(settings.showLineEndCommentSwiftBase);
mySettingsComponent.setShowLineEndCommentSql(settings.showLineEndCommentSql); mySettingsComponent.setShowLineEndCommentSql(settings.showLineEndCommentSql);
mySettingsComponent.setShowLineEndCommentJson(settings.showLineEndCommentJson); mySettingsComponent.setShowLineEndCommentJson(settings.showLineEndCommentJson);
mySettingsComponent.setShowLineEndCommentYaml(settings.showLineEndCommentYaml);
mySettingsComponent.setTreeTags(String.join("|", settings.treeTags)); mySettingsComponent.setTreeTags(String.join("|", settings.treeTags));
mySettingsComponent.setLineTags(String.join("|", settings.lineTags)); mySettingsComponent.setLineTags(String.join("|", settings.lineTags));

View File

@@ -51,6 +51,7 @@ public class AppSettingsState implements PersistentStateComponent<AppSettingsSta
public boolean showLineEndCommentSwiftBase = true; public boolean showLineEndCommentSwiftBase = true;
public boolean showLineEndCommentSql = true; public boolean showLineEndCommentSql = true;
public boolean showLineEndCommentJson = true; public boolean showLineEndCommentJson = true;
public boolean showLineEndCommentYaml = true;
@NotNull @NotNull
public String[] treeTags = {"author"}; public String[] treeTags = {"author"};

View File

@@ -13,6 +13,7 @@ Show doc comment in the Project view Tree, line End, json, other
<li>Java, Kotlin, Groovy, Scala <li>Java, Kotlin, Groovy, Scala
<li>C/C++/OC, Python, Go, Rust, Ruby <li>C/C++/OC, Python, Go, Rust, Ruby
<li>JS/TS, PHP, SQL <li>JS/TS, PHP, SQL
<li>YAML/yml
</ul> </ul>
<h4>English Note</h4> <h4>English Note</h4>
@@ -136,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="ruby.xml">com.intellij.modules.ruby</depends>
<depends optional="true" config-file="c.xml">com.intellij.modules.clion</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="swift.xml">com.intellij.modules.swift.lang</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>--> <!--<depends optional="true" config-file="cs.xml">com.intellij.modules.rider</depends>-->
<applicationListeners> <applicationListeners>

View File

@@ -0,0 +1,5 @@
<idea-plugin>
<extensions defaultExtensionNs="com.intellij">
<editor.linePainter implementation="io.github.linwancen.plugin.show.lang.YamlLangDoc"/>
</extensions>
</idea-plugin>