简体   繁体   English

在 vscode“查找所有引用?”中显示 function 名称?

[英]Show function names in vscode "Find All References?"

Shift+F12 in Visual Studio Code shows the references to a function or variable. Visual Studio Code 中的 Shift+F12 显示对 function 或变量的引用。 Is it possible to make it also show what function each hit belongs to?是否有可能让它也显示每次点击属于什么 function?

Current right side view:当前右侧视图:

main.c
  close()
  close()
runner.c
  close()
system.c
  void close()

What I want:我想要的是:

main.c
  main(): close()
  control(): close()
runner.c
  abort(): close()
system.c
  void close()

At the moment, I find that I need to click each hit and scroll a bit to see what function it belongs to.目前,我发现我需要单击每个命中并稍微滚动一下以查看它属于哪个 function。

This question mentions Resharper, but I'm writing C code: Show method name in "Find all references" - C# Visual Studio这个问题提到了 Resharper,但我正在编写 C 代码: 在“查找所有引用”中显示方法名称 - C# Visual Studio

The same problem.同样的问题。 source insight has this feature. source insight 具有此功能。

The short answer is "No," there is no current mechanism by which to make VSCode show what you are requesting.简短的回答是“否”,目前没有任何机制可以让 VSCode 显示您的请求。

I prefer to use VisualStudio for c and c++, but sadly there also is no current mechanism to make VisualStudio show anything more than the definition, project, file, and line/column at which a reference was found.我更喜欢将 VisualStudio 用于 c 和 c++,但遗憾的是,目前没有任何机制可以让 VisualStudio 显示除定义、项目、文件和找到引用的行/列之外的任何内容。 IMO it is reasonable to consider both VS and VSCode together here because I believe it highly likely that if this particular feature makes it into one, it will make it into both. IMO 在这里将 VS 和 VSCode 一起考虑是合理的,因为我相信如果这个特定的功能成为一个,它很可能会成为两者。

It appears that users of VisualStudio have been requesting the name of the function (or method) in which the reference was found (ie, the exact same feature you are seeking) for many years.多年来,VisualStudio 的用户似乎一直在请求找到引用的 function(或方法)的名称(即,与您正在寻找的功能完全相同)。 The request has repeatedly been closed with a statement that insufficient upvotes show this is not a high enough priority.该请求一再被关闭,并声明没有足够的赞成票表明这不是一个足够高的优先级。

In general, feature requests are prioritized against everything the dev team already needs/wants to do and everything else that has been requested by users and has made it through some preliminary screening.一般来说,功能请求的优先级高于开发团队已经需要/想要做的所有事情,以及用户已经请求并通过一些初步筛选的所有其他事情。 If you really care about this functionality you probably would need to re-submit it and mobilize community support to upvote it as a requested feature.如果您真的关心此功能,您可能需要重新提交它并动员社区支持将其作为请求的功能进行投票。 Here's the wiki link explaining the process 这是解释该过程的维基链接

IMO this shortcoming of is one of a group of failings that together create the market for add-on products like Resharper and competing products such as Source Insight. IMO 的这个缺点是一组失败之一,它们共同为 Resharper 等附加产品和 Source Insight 等竞争产品创造了市场。

There is a dumb workaround that I use in VisualStudio.我在 VisualStudio 中使用了一个愚蠢的解决方法。 I do not know whether it will have the same effect in VSCode, but I will share it here in case it helps somebody.我不知道它是否会在 VSCode 中产生相同的效果,但我会在这里分享它以防它对某人有所帮助。 In VS, each displayed reference also displays any comment that was placed on the same line as the reference.在 VS 中,每个显示的引用还会显示与引用放在同一行的任何注释。 This means I can do something like:这意味着我可以做类似的事情:

void funcOne()
{
   // your code here
   close(); //[Call from funcOne]
}
void funcTwo()
{
   // your code here
   close(); //[Call from funcTwo]
}

The FindReferences window then makes it possible to see the source of each reference without needing to open each one. FindReferences window 使查看每个参考文献的来源成为可能,而无需打开每个参考文献。 The attached image shows what this looks like in VisualStudio CommunityEdition 2022 (I happen to be working in c++ for embedded processors using the VisualMicro add-on, but the described behavior is innate to VisualStudio's Find References function).所附图片显示了这在 VisualStudio CommunityEdition 2022 中的样子(我碰巧在 c++ 工作,用于使用 VisualMicro 附加组件的嵌入式处理器,但所描述的行为是 VisualStudio 的 Find References 功能固有的)。

屏幕截图

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM