feat(SwiftLangDoc): support Swift | 支持 Swift

This commit is contained in:
林万程
2024-02-20 21:25:58 +08:00
parent 335d9fffff
commit 82081ae8ec
8 changed files with 62 additions and 2 deletions

View File

@@ -40,6 +40,8 @@ intellij {
if ('IC' == ideTypeStr || 'IU' == ideTypeStr) {
plugins.add('java')
plugins.add('org.jetbrains.kotlin')
} else if ('CL' == ideTypeStr) {
plugins.add('com.intellij.clion-swift:201.6668.126')
}
if (!ideTypeStr.endsWith('C')) {
plugins.add('JavaScript')

View File

@@ -0,0 +1,37 @@
package io.github.linwancen.plugin.show.lang;
import com.intellij.psi.PsiElement;
import com.jetbrains.cidr.lang.psi.OCReferenceElement;
import com.jetbrains.swift.SwiftLanguage;
import com.jetbrains.swift.psi.SwiftReferenceElement;
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 SwiftLangDoc extends BaseLangDoc {
static {
LANG_DOC_MAP.put(SwiftLanguage.INSTANCE.getID(), new SwiftLangDoc());
}
@Override
public @NotNull List<Class<? extends PsiElement>> getRefClass() {
// guess
return List.of(SwiftReferenceElement.class);
}
@Override
public boolean show(@NotNull LineInfo info) {
return info.appSettings.showLineEndCommentSwiftBase;
}
@Override
protected @Nullable <T extends SettingsInfo> String resolveDocPrint(@NotNull T info, @NotNull PsiElement resolve) {
// Copy from C
return super.resolveDocPrint(info, resolve.getParent());
}
}

View File

@@ -35,6 +35,7 @@ public class AppSettingsComponent {
private final JBCheckBox showLineEndCommentGoBase = new JBCheckBox("// Go ");
private final JBCheckBox showLineEndCommentRustBase = new JBCheckBox("// Rust ");
private final JBCheckBox showLineEndCommentCBase = new JBCheckBox("// C ");
private final JBCheckBox showLineEndCommentSwiftBase = new JBCheckBox("// Swift ");
private final JBCheckBox showLineEndCommentSql = new JBCheckBox(" sql ");
private final JBCheckBox showLineEndCommentJson = new JBCheckBox(" json ");
private final JBTextField lineTags = new JBTextField();
@@ -82,7 +83,8 @@ public class AppSettingsComponent {
showLineEndCommentPhpBase,
showLineEndCommentPyBase,
showLineEndCommentRustBase,
showLineEndCommentCBase
showLineEndCommentCBase,
showLineEndCommentSwiftBase
), 1)
.addLabeledComponent(new JBLabel(ShowBundle.message("tree.tags")), treeTags, 1, true)
.addLabeledComponent(new JBLabel(ShowBundle.message("line.tags")), lineTags, 1, true)
@@ -278,6 +280,14 @@ public class AppSettingsComponent {
showLineEndCommentCBase.setSelected(newStatus);
}
public boolean getShowLineEndCommentSwiftBase() {
return showLineEndCommentSwiftBase.isSelected();
}
public void setShowLineEndCommentSwiftBase(boolean newStatus) {
showLineEndCommentSwiftBase.setSelected(newStatus);
}
public boolean getShowLineEndCommentSql() {
return showLineEndCommentSql.isSelected();
}

View File

@@ -55,6 +55,7 @@ public class AppSettingsConfigurable implements Configurable {
modified |= mySettingsComponent.getShowLineEndCommentGoBase() != settings.showLineEndCommentGoBase;
modified |= mySettingsComponent.getShowLineEndCommentRustBase() != settings.showLineEndCommentRustBase;
modified |= mySettingsComponent.getShowLineEndCommentCBase() != settings.showLineEndCommentCBase;
modified |= mySettingsComponent.getShowLineEndCommentSwiftBase() != settings.showLineEndCommentSwiftBase;
modified |= mySettingsComponent.getShowLineEndCommentSql() != settings.showLineEndCommentSql;
modified |= mySettingsComponent.getShowLineEndCommentJson() != settings.showLineEndCommentJson;
@@ -98,6 +99,7 @@ public class AppSettingsConfigurable implements Configurable {
settings.showLineEndCommentGoBase = mySettingsComponent.getShowLineEndCommentGoBase();
settings.showLineEndCommentRustBase = mySettingsComponent.getShowLineEndCommentRustBase();
settings.showLineEndCommentCBase = mySettingsComponent.getShowLineEndCommentCBase();
settings.showLineEndCommentSwiftBase = mySettingsComponent.getShowLineEndCommentSwiftBase();
settings.showLineEndCommentSql = mySettingsComponent.getShowLineEndCommentSql();
settings.showLineEndCommentJson = mySettingsComponent.getShowLineEndCommentJson();
@@ -144,6 +146,7 @@ public class AppSettingsConfigurable implements Configurable {
mySettingsComponent.setShowLineEndCommentGoBase(settings.showLineEndCommentGoBase);
mySettingsComponent.setShowLineEndCommentRustBase(settings.showLineEndCommentRustBase);
mySettingsComponent.setShowLineEndCommentCBase(settings.showLineEndCommentCBase);
mySettingsComponent.setShowLineEndCommentSwiftBase(settings.showLineEndCommentSwiftBase);
mySettingsComponent.setShowLineEndCommentSql(settings.showLineEndCommentSql);
mySettingsComponent.setShowLineEndCommentJson(settings.showLineEndCommentJson);

View File

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

View File

@@ -122,13 +122,15 @@ Show doc comment at the Project view Tree, line End, json, other
<depends optional="true" config-file="kotlin.xml">org.jetbrains.kotlin</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>
<depends optional="true" config-file="python.xml">com.intellij.modules.python</depends>
<depends optional="true" config-file="go.xml">org.jetbrains.plugins.go</depends>
<!-- old version -->
<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="c.xml">com.intellij.modules.c-capable</depends>
<depends optional="true" config-file="php.xml">com.jetbrains.php</depends>
<depends optional="true" config-file="swift.xml">com.intellij.modules.swift-capable</depends>
<!--suppress PluginXmlValidity, MybatisMapperXmlInspection -->
<!--<depends optional="true" config-file="cs.xml">com.intellij.modules.rider</depends>-->

View File

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