feat(CLangDoc): support C | 支持 C
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
package io.github.linwancen.plugin.show.lang;
|
||||
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.jetbrains.cidr.lang.OCLanguage;
|
||||
import com.jetbrains.cidr.lang.psi.OCReferenceElement;
|
||||
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 java.util.List;
|
||||
|
||||
public class CLangDoc extends BaseLangDoc {
|
||||
|
||||
static {
|
||||
LANG_DOC_MAP.put(OCLanguage.getInstance().getID(), new CLangDoc());
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull List<Class<? extends PsiElement>> getRefClass() {
|
||||
return List.of(OCReferenceElement.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean show(@NotNull LineInfo info) {
|
||||
return info.appSettings.showLineEndCommentCBase;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected @Nullable <T extends SettingsInfo> String resolveDocPrint(@NotNull T info, @NotNull PsiElement resolve) {
|
||||
return super.resolveDocPrint(info, resolve.getParent());
|
||||
}
|
||||
}
|
||||
@@ -34,6 +34,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 showLineEndCommentCBase = new JBCheckBox("// C ");
|
||||
private final JBCheckBox showLineEndCommentSql = new JBCheckBox(" sql ");
|
||||
private final JBCheckBox showLineEndCommentJson = new JBCheckBox(" json ");
|
||||
private final JBTextField lineTags = new JBTextField();
|
||||
@@ -80,7 +81,8 @@ public class AppSettingsComponent {
|
||||
showLineEndCommentJsBase,
|
||||
showLineEndCommentPhpBase,
|
||||
showLineEndCommentPyBase,
|
||||
showLineEndCommentRustBase
|
||||
showLineEndCommentRustBase,
|
||||
showLineEndCommentCBase
|
||||
), 1)
|
||||
.addLabeledComponent(new JBLabel(ShowBundle.message("tree.tags")), treeTags, 1, true)
|
||||
.addLabeledComponent(new JBLabel(ShowBundle.message("line.tags")), lineTags, 1, true)
|
||||
@@ -268,6 +270,14 @@ public class AppSettingsComponent {
|
||||
showLineEndCommentRustBase.setSelected(newStatus);
|
||||
}
|
||||
|
||||
public boolean getShowLineEndCommentCBase() {
|
||||
return showLineEndCommentCBase.isSelected();
|
||||
}
|
||||
|
||||
public void setShowLineEndCommentCBase(boolean newStatus) {
|
||||
showLineEndCommentCBase.setSelected(newStatus);
|
||||
}
|
||||
|
||||
public boolean getShowLineEndCommentSql() {
|
||||
return showLineEndCommentSql.isSelected();
|
||||
}
|
||||
|
||||
@@ -54,6 +54,7 @@ public class AppSettingsConfigurable implements Configurable {
|
||||
modified |= mySettingsComponent.getShowLineEndCommentPyBase() != settings.showLineEndCommentPyBase;
|
||||
modified |= mySettingsComponent.getShowLineEndCommentGoBase() != settings.showLineEndCommentGoBase;
|
||||
modified |= mySettingsComponent.getShowLineEndCommentRustBase() != settings.showLineEndCommentRustBase;
|
||||
modified |= mySettingsComponent.getShowLineEndCommentCBase() != settings.showLineEndCommentCBase;
|
||||
modified |= mySettingsComponent.getShowLineEndCommentSql() != settings.showLineEndCommentSql;
|
||||
modified |= mySettingsComponent.getShowLineEndCommentJson() != settings.showLineEndCommentJson;
|
||||
|
||||
@@ -96,6 +97,7 @@ public class AppSettingsConfigurable implements Configurable {
|
||||
settings.showLineEndCommentPyBase = mySettingsComponent.getShowLineEndCommentPyBase();
|
||||
settings.showLineEndCommentGoBase = mySettingsComponent.getShowLineEndCommentGoBase();
|
||||
settings.showLineEndCommentRustBase = mySettingsComponent.getShowLineEndCommentRustBase();
|
||||
settings.showLineEndCommentCBase = mySettingsComponent.getShowLineEndCommentCBase();
|
||||
settings.showLineEndCommentSql = mySettingsComponent.getShowLineEndCommentSql();
|
||||
settings.showLineEndCommentJson = mySettingsComponent.getShowLineEndCommentJson();
|
||||
|
||||
@@ -141,6 +143,7 @@ public class AppSettingsConfigurable implements Configurable {
|
||||
mySettingsComponent.setShowLineEndCommentPyBase(settings.showLineEndCommentPyBase);
|
||||
mySettingsComponent.setShowLineEndCommentGoBase(settings.showLineEndCommentGoBase);
|
||||
mySettingsComponent.setShowLineEndCommentRustBase(settings.showLineEndCommentRustBase);
|
||||
mySettingsComponent.setShowLineEndCommentCBase(settings.showLineEndCommentCBase);
|
||||
mySettingsComponent.setShowLineEndCommentSql(settings.showLineEndCommentSql);
|
||||
mySettingsComponent.setShowLineEndCommentJson(settings.showLineEndCommentJson);
|
||||
|
||||
|
||||
@@ -42,6 +42,7 @@ public class AppSettingsState implements PersistentStateComponent<AppSettingsSta
|
||||
public boolean showLineEndCommentGo = true;
|
||||
public boolean showLineEndCommentGoBase = false;
|
||||
public boolean showLineEndCommentRustBase = true;
|
||||
public boolean showLineEndCommentCBase = true;
|
||||
public boolean showLineEndCommentSql = true;
|
||||
public boolean showLineEndCommentJson = true;
|
||||
|
||||
|
||||
Binary file not shown.
5
src/main/resources/META-INF/c.xml
Normal file
5
src/main/resources/META-INF/c.xml
Normal file
@@ -0,0 +1,5 @@
|
||||
<idea-plugin>
|
||||
<extensions defaultExtensionNs="com.intellij">
|
||||
<editor.linePainter implementation="io.github.linwancen.plugin.show.lang.CLangDoc"/>
|
||||
</extensions>
|
||||
</idea-plugin>
|
||||
@@ -11,7 +11,7 @@ Show doc comment at the Project view Tree, line End, json, other
|
||||
|
||||
<h2>English Note</h2>
|
||||
<ul>
|
||||
<li>support Java Kotlin JS/TS PHP Python Go Rust SQL
|
||||
<li>support Java Kotlin JS/TS PHP Python Go Rust 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
|
||||
@@ -54,8 +54,9 @@ Show doc comment at the Project view Tree, line End, json, other
|
||||
<hr>
|
||||
<h2>中文说明</h2>
|
||||
<ul>
|
||||
<li>在行末尾显示 引用对象的文档注释,支持 Java Kotlin JS/TS PHP Python Go Rust SQL
|
||||
<li>在结构树显示 文件注释 或 项目说明 (README.md pom.xml 等,可设置)
|
||||
<li>在行末尾显示 引用对象的文档注释,欢迎反馈您想要支持的语言,目前 C# 有技术问题待官方解决
|
||||
<li>目前支持 Java Kotlin JS/TS PHP Python Go Rust C SQL
|
||||
<li>输入 doc / docc 等生成 /** */
|
||||
<li>json 字段注释从 xxx.json.tsv 读取
|
||||
<li>json 字典注释从 键名.tsv 读取
|
||||
@@ -126,6 +127,7 @@ Show doc comment at the Project view Tree, line End, json, other
|
||||
<!-- old version -->
|
||||
<depends optional="true" config-file="rust_old.xml">org.rust.lang</depends>
|
||||
<depends optional="true" config-file="rust.xml">com.jetbrains.rust</depends>
|
||||
<depends optional="true" config-file="c.xml">com.intellij.modules.c-capable</depends>
|
||||
<depends optional="true" config-file="php.xml">com.jetbrains.php</depends>
|
||||
<!--suppress PluginXmlValidity, MybatisMapperXmlInspection -->
|
||||
<!--<depends optional="true" config-file="cs.xml">com.intellij.modules.rider</depends>-->
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
#include <stdio.h>
|
||||
|
||||
/*
|
||||
* a
|
||||
*/
|
||||
int a = 1;
|
||||
|
||||
int main() {
|
||||
print()
|
||||
int b = a;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* OCReferenceElement
|
||||
* Language: ObjectiveC
|
||||
*/
|
||||
void print(){
|
||||
printf("Hello, World!\n");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user