feat(CLangDoc): support C | 支持 C

This commit is contained in:
林万程
2024-02-09 15:59:58 +08:00
parent 62c52fa93d
commit 335d9fffff
10 changed files with 90 additions and 15 deletions

View File

@@ -13,7 +13,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
@@ -56,8 +56,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 读取
@@ -120,7 +121,7 @@ Show doc comment at the Project view Tree, line End, json, other
<h2>English Change Notes:</h2>
<ul>
<li>2.16 Add line-end-comment support Rust, PHP
<li>2.16 Add line-end-comment support Rust, PHP, C/C++/Object C
<li>2.15 Add line-end-comment java anno doc
<li>2.14 Add line-end-comment java enum doc for Yes(1, "Yes")
<li>2.13 ★ Cache for 2023.3
@@ -165,7 +166,7 @@ Show doc comment at the Project view Tree, line End, json, other
<h2>中文更新说明:</h2>
<ul>
<li>2.16 增加 行末注释 支持 Rust, PHP
<li>2.16 增加 行末注释 支持 Rust, PHP, C/C++/Object C
<li>2.15 增加 行末注释 java 注解注释
<li>2.14 增加 行末注释 java 枚举注释用于 Yes(1, "是")
<li>2.13 ★ 缓存用于支持 2023.3

View File

@@ -57,9 +57,10 @@ sourceSets {
srcDirs = ['src/main/java', 'src/main/rider']
}
}
test {
} else if ('CL' == ideTypeStr) {
main {
java {
srcDirs = ['src/test/java', 'src/test/rider']
srcDirs = ['src/main/java', 'src/main/clion']
}
}
} else {
@@ -67,10 +68,8 @@ sourceSets {
java {
srcDirs = ['src/main/java', 'src/main/idea']
}
}
test {
java {
srcDirs = ['src/test/java', 'src/test/idea']
resources {
srcDirs = ['src/main/resources', 'src/main/other_lang_class']
}
}
}
@@ -93,7 +92,7 @@ patchPluginXml {
changeNotes = """
<h2>English Change Notes:</h2>
<ul>
<li>2.16 Add line-end-comment support Rust, PHP
<li>2.16 Add line-end-comment support Rust, PHP, C/C++/Object C
<li>2.15 Add line-end-comment java anno doc
<li>2.14 Add line-end-comment java enum doc for Yes(1, "Yes")
<li>2.13 ★ Cache for 2023.3
@@ -138,7 +137,7 @@ patchPluginXml {
<h2>中文更新说明:</h2>
<ul>
<li>2.16 增加 行末注释 支持 Rust, PHP
<li>2.16 增加 行末注释 支持 Rust, PHP, C/C++/Object C
<li>2.15 增加 行末注释 java 注解注释
<li>2.14 增加 行末注释 java 枚举注释用于 Yes(1, "是")
<li>2.13 ★ 缓存用于支持 2023.3

View File

@@ -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());
}
}

View File

@@ -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();
}

View File

@@ -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);

View File

@@ -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;

View File

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

View File

@@ -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>-->

View File

@@ -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");
}