如何扩展 IntelliSense 项目? [英] How to extend IntelliSense items?

查看:20
本文介绍了如何扩展 IntelliSense 项目?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想通过各种项目手动扩展 IntelliSense 列表.我想对项目触发的操作负责(即代码完成和工具提示信息).什么物品都无所谓.

这是否可以通过 VisualStudio 插件、ReSharper/DXCore 或任何其他插件实现?

背景:

你们中的一些人可能知道 FOP(面向功能的编程).FOP 需要对智能感知和编辑器行为进行各种更改.

另一个有趣的帖子.

解决方案

这绝对可以通过 编写 ReSharper 插件.

  • 首先实现 ICodeCompletionItemsProvider,它将提供额外的 IntelliSense 项目.最简单的方法是从 ItemsProviderOfSpecificContext 继承(如果您对 C# 代码完成感兴趣,TContextCSharpCodeCompletionContext).>

  • 您的提供者将在 AddLookupItems() 的实现中添加额外的项目.您有机会在此处提供 ILookupItem 的自定义实现:当用户在完成弹出窗口中选择项目时,将调用此接口的 Accept() 方法.这是您执行所需代码的机会.

请注意,此信息适用于 R# 6.1/7.0.不过,我认为它与以前的版本没有太大区别.显然,您必须启用 ReSharper IntelliSense 而不是 Visual Studio IntelliSense 才能使其工作.

I would like to manually extend the IntelliSense list by various items. I want to be responsible for the action triggered by the item (i.e. code completion and tooltip info). It doesn't matter what items.

Is this possible with an VisualStudio add-in, ReSharper / DXCore or any otherg plugin?

Background:

Some of you may know FOP (feature-oriented programming). FOP would require various changes to intellisense and editor behavior.

Edit:

Another interesting post.

解决方案

This is definitely doable very easily by writing a ReSharper plugin.

  • Start by implementing ICodeCompletionItemsProvider which will provide additional IntelliSense items. The easiest way is to inherit from ItemsProviderOfSpecificContext<TContext> (with TContext being CSharpCodeCompletionContext if you're interested in C# code completion).

  • Your provider will add the additional items in the implementation of AddLookupItems(). You have the chance to provide a custom implementation of ILookupItem here: the Accept() method of this interface will be called when the user chooses the item in the completion popup. Here is your chance to execute the code you need.

Note that this information is for R# 6.1/7.0. I don't think it is much different in previous versions though. Obviously, you have to enable ReSharper IntelliSense instead of Visual Studio IntelliSense for this to work.

这篇关于如何扩展 IntelliSense 项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆