How to get CSharp References comment
已回答
Many people have asked me to support Rider, and I have been researching for a long time.
Other languages can obtain comments using psiElement.getReferences().resolve().
C # does not have an object that can getReferences().
how should I obtain reference comments?
My Plugins: https://plugins.jetbrains.com/plugin/18553-show-comment
@Nullable
protected String refDoc(@NotNull LineInfo info, @NotNull PsiElement ref) {
// kotlin ref.getReference() == null but ref.getReferences().length == 2
@NotNull PsiReference[] references = ref.getReferences();
if (references.length < 1) {
return null;
}
for (@NotNull PsiReference reference : references) {
@Nullable PsiElement resolve;
try {
resolve = reference.resolve();
@Override
public @NotNull List<Class<? extends PsiElement>> getRefClass() {
return List.of(JSPsiReferenceElement.class);
}
请先登录再写评论。
Hi,
Rider doesn't operate on a real PSI tree, and all PSI-related operations should be implemented in the Rider part of the plugin. See:
Can you give me some code references or class names? After reading the content in the link, I still don't know how to do it.
Hi linwancheng ,
Rider uses the ReSharper SDK (i.e., not the IntelliJ SDK) to parse C# syntax. Therefore, expect to write C#/.NET to support your feature. I think the inspections sample project could be helpful to get started with how things are working. Since I expect you also want to use some of your existing infrastructure, you must send data between C# and Kotlin code. For that, I recommend looking into the protocol sample project (check the README).