feat(RubyLangDoc): support Ruby | 支持 Ruby

This commit is contained in:
林万程
2024-02-28 07:30:30 +08:00
parent e654e960d2
commit b352dbb9ff
9 changed files with 94 additions and 10 deletions

View File

@@ -0,0 +1,28 @@
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.lang.base.BaseLangDoc;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.plugins.ruby.ruby.lang.RubyLanguage;
import org.jetbrains.plugins.ruby.ruby.lang.psi.references.RDotReference;
import org.jetbrains.plugins.ruby.ruby.lang.psi.variables.RIdentifier;
import java.util.List;
public class RubyLangDoc extends BaseLangDoc {
static {
LANG_DOC_MAP.put(RubyLanguage.INSTANCE.getID(), new RubyLangDoc());
}
@Override
public @NotNull List<Class<? extends PsiElement>> getRefClass() {
return List.of(RDotReference.class, RIdentifier.class);
}
@Override
public boolean show(@NotNull LineInfo info) {
return info.appSettings.showLineEndCommentRubyBase;
}
}

View File

@@ -38,6 +38,7 @@ public class AppSettingsComponent {
private final JBCheckBox showLineEndCommentGo = new JBCheckBox(" Go ");
private final JBCheckBox showLineEndCommentGoBase = new JBCheckBox("// Go ");
private final JBCheckBox showLineEndCommentRustBase = new JBCheckBox("// Rust ");
private final JBCheckBox showLineEndCommentRubyBase = new JBCheckBox("// Ruby ");
private final JBCheckBox showLineEndCommentCBase = new JBCheckBox("// C ");
private final JBCheckBox showLineEndCommentSwiftBase = new JBCheckBox("// Swift ");
private final JBCheckBox showLineEndCommentSql = new JBCheckBox(" sql ");
@@ -318,6 +319,14 @@ public class AppSettingsComponent {
showLineEndCommentRustBase.setSelected(newStatus);
}
public boolean getShowLineEndCommentRubyBase() {
return showLineEndCommentRubyBase.isSelected();
}
public void setShowLineEndCommentRubyBase(boolean newStatus) {
showLineEndCommentRubyBase.setSelected(newStatus);
}
public boolean getShowLineEndCommentCBase() {
return showLineEndCommentCBase.isSelected();
}

View File

@@ -58,6 +58,7 @@ public class AppSettingsConfigurable implements Configurable {
modified |= mySettingsComponent.getShowLineEndCommentPyBase() != settings.showLineEndCommentPyBase;
modified |= mySettingsComponent.getShowLineEndCommentGoBase() != settings.showLineEndCommentGoBase;
modified |= mySettingsComponent.getShowLineEndCommentRustBase() != settings.showLineEndCommentRustBase;
modified |= mySettingsComponent.getShowLineEndCommentRubyBase() != settings.showLineEndCommentRubyBase;
modified |= mySettingsComponent.getShowLineEndCommentCBase() != settings.showLineEndCommentCBase;
modified |= mySettingsComponent.getShowLineEndCommentSwiftBase() != settings.showLineEndCommentSwiftBase;
modified |= mySettingsComponent.getShowLineEndCommentSql() != settings.showLineEndCommentSql;
@@ -106,6 +107,7 @@ public class AppSettingsConfigurable implements Configurable {
settings.showLineEndCommentPyBase = mySettingsComponent.getShowLineEndCommentPyBase();
settings.showLineEndCommentGoBase = mySettingsComponent.getShowLineEndCommentGoBase();
settings.showLineEndCommentRustBase = mySettingsComponent.getShowLineEndCommentRustBase();
settings.showLineEndCommentRubyBase = mySettingsComponent.getShowLineEndCommentRubyBase();
settings.showLineEndCommentCBase = mySettingsComponent.getShowLineEndCommentCBase();
settings.showLineEndCommentSwiftBase = mySettingsComponent.getShowLineEndCommentSwiftBase();
settings.showLineEndCommentSql = mySettingsComponent.getShowLineEndCommentSql();
@@ -157,6 +159,7 @@ public class AppSettingsConfigurable implements Configurable {
mySettingsComponent.setShowLineEndCommentPyBase(settings.showLineEndCommentPyBase);
mySettingsComponent.setShowLineEndCommentGoBase(settings.showLineEndCommentGoBase);
mySettingsComponent.setShowLineEndCommentRustBase(settings.showLineEndCommentRustBase);
mySettingsComponent.setShowLineEndCommentRubyBase(settings.showLineEndCommentRubyBase);
mySettingsComponent.setShowLineEndCommentCBase(settings.showLineEndCommentCBase);
mySettingsComponent.setShowLineEndCommentSwiftBase(settings.showLineEndCommentSwiftBase);
mySettingsComponent.setShowLineEndCommentSql(settings.showLineEndCommentSql);

View File

@@ -46,6 +46,7 @@ public class AppSettingsState implements PersistentStateComponent<AppSettingsSta
public boolean showLineEndCommentGo = true;
public boolean showLineEndCommentGoBase = false;
public boolean showLineEndCommentRustBase = true;
public boolean showLineEndCommentRubyBase = true;
public boolean showLineEndCommentCBase = true;
public boolean showLineEndCommentSwiftBase = true;
public boolean showLineEndCommentSql = true;

View File

@@ -11,7 +11,7 @@ Show doc comment in the Project view Tree, line End, json, other
<h2>English Note</h2>
<ul>
<li>support Java Kotlin Scala Groovy JS/TS PHP Python Go Rust C SQL
<li>support Java Kotlin Scala Groovy JS/TS PHP Python Go Rust Ruby C SQL
<li>tree doc from lang or README.md pom .gradle etc. by settings
<li>input `doc` `docc` -> /** */
<li>json doc from xxx.json.tsv
@@ -56,7 +56,7 @@ Show doc comment in the Project view Tree, line End, json, other
<ul>
<li>在结构树显示 文件注释 或 项目说明 (README.md pom.xml 等,可设置)
<li>在行末尾显示 引用对象的文档注释,欢迎反馈您想要支持的语言,欢迎 C# 大神研究 CsLineEnd.java
<li>目前支持 Java Kotlin Scala Groovy JS/TS PHP Python Go Rust C SQL
<li>目前支持 Java Kotlin Scala Groovy JS/TS PHP Python Go Rust Ruby C SQL
<li>输入 doc / docc 等生成 /** */
<li>json 字段注释从 xxx.json.tsv 读取
<li>json 字典注释从 键名.tsv 读取
@@ -120,9 +120,9 @@ Show doc comment in the Project view Tree, line End, json, other
<depends>com.intellij.modules.platform</depends>
<depends optional="true" config-file="java.xml">com.intellij.modules.java</depends>
<depends optional="true" config-file="kotlin.xml">org.jetbrains.kotlin</depends>
<depends optional="true" config-file="groovy.xml">org.intellij.groovy</depends>
<!--suppress PluginXmlValidity -->
<depends optional="true" config-file="scala.xml">org.intellij.scala</depends>
<depends optional="true" config-file="groovy.xml">org.intellij.groovy</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="php.xml">com.jetbrains.php</depends>
@@ -132,6 +132,7 @@ Show doc comment in the Project view Tree, line End, json, other
<depends optional="true" config-file="rust_old.xml">org.rust.lang</depends>
<!--suppress PluginXmlValidity -->
<depends optional="true" config-file="rust.xml">com.jetbrains.rust</depends>
<depends optional="true" config-file="ruby.xml">com.intellij.modules.ruby</depends>
<!--suppress PluginXmlValidity -->
<depends optional="true" config-file="c.xml">com.intellij.modules.clion</depends>
<!--suppress PluginXmlValidity -->

View File

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

View File

@@ -0,0 +1,36 @@
lwc = Human.new("lwc")
lwc.met1("Hi")
# fun
def fun(x,y)
fun2
fun3("Hi")
h = Human.new
h.met2
end
# fun2
def fun2()
end
# fun3
def fun3(msg)
end
# class
class Human
# Human
# met1 #met2
def met1(msg)
met2
end
# met2
def met2
end
end