From e60ad5722e23694271255efc8c2a8b6a4061849d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9E=97=E4=B8=87=E7=A8=8B?= <1498425439@qq.com> Date: Sun, 28 Jul 2024 17:20:00 +0800 Subject: [PATCH] fix(RustLangDoc): support rust package comment //! fixed #55 --- .../linwancen/plugin/show/lang/RustLangDoc.java | 12 ++++++++++++ .../io/github/linwancen/plugin/show/demo/main.rs | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/main/java/io/github/linwancen/plugin/show/lang/RustLangDoc.java b/src/main/java/io/github/linwancen/plugin/show/lang/RustLangDoc.java index a036ce5..410aa22 100644 --- a/src/main/java/io/github/linwancen/plugin/show/lang/RustLangDoc.java +++ b/src/main/java/io/github/linwancen/plugin/show/lang/RustLangDoc.java @@ -2,8 +2,10 @@ 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.rust.lang.RsLanguage; import org.rust.lang.core.psi.RsMethodCall; import org.rust.lang.core.psi.RsPath; @@ -25,4 +27,14 @@ public class RustLangDoc extends BaseLangDoc { public boolean show(@NotNull LineInfo info) { return info.appSettings.showLineEndCommentRustBase; } + + @Nullable + @Override + protected String resolveDocPrint(@NotNull T info, @NotNull PsiElement resolve) { + String s = super.resolveDocPrint(info, resolve); + if (s != null && s.startsWith("!")) { + return s.substring(1); + } + return s; + } } diff --git a/src/test/java/io/github/linwancen/plugin/show/demo/main.rs b/src/test/java/io/github/linwancen/plugin/show/demo/main.rs index f2cf3a2..b870158 100644 --- a/src/test/java/io/github/linwancen/plugin/show/demo/main.rs +++ b/src/test/java/io/github/linwancen/plugin/show/demo/main.rs @@ -1,4 +1,4 @@ -// file tree doc is any where not doc comment +//! file tree doc is any where not doc comment fn main() { my_fun()