CodeRush 中自动添加 `using`

发布于 2024-09-02 06:09:28 字数 684 浏览 3 评论 0原文

我刚刚安装了 Visual Studio 的 CodeRush Pro(评估试用版),到目前为止我可以说我非常喜欢它。与 Resharper 相比,我真正缺少的只是一种功能。这是 CodeRush 处理 using 的方式。当我输入一些未在 using 中列出的包中声明的类名时,CodeRush 将其用红色下划线作为错误(它是什么),但是如果我将光标悬停在它上面,它不会让我添加 using,它只是说它是“未声明的元素”。

我必须使用 VS 默认使用加法(将脱字符号移至标识符,将光标悬停在第一个字母下出现的小方框上,单击出现的按钮,然后从下拉列表中选择例如 using System菜单)。

当我将光标悬停在突出显示的“问题”(即未声明的元素)上时,有没有办法配置 CodeRush 以提供 mi add 使用?

第二部分是 Resharper 有一种称为“类型名称完成”的想法。它改进了智能感知。假设您的文件中没有 using 声明。然后输入类似 ICompar 的内容并按 CTRL+SPACE。当然不会有任何建议。但是使用 Resharper,您可以按 CTRL+ALT+SPACE,然后您会得到所有以 ICompar 开头的类的建议,即使它们没有在使用中。当您选择其中之一时,系统会自动为您添加正确的用法。

有没有办法让 CodeRush 这样做?

I just installed CodeRush Pro (evaluation trial) for Visual Studio and I can say I like it much so far. Comparing to Resharper there is only one type of feature I'm really missing. It is the way CodeRush deals with using. When I type some class name that is not declared in some package listed in using, CodeRush underlines it red as an error(what it is) but if I hover over it with cursor it does not offer me to add using, it merely says it is "Undeclared element".

I have to use VS default using addition (move caret to the identifier, hover cursor over that really small box that appears under first letter, click the button that appears and choose for example using System form a drop down menu).

Is there a way how to configure CodeRush to offer mi add using when I hover a cursor over highlighted "issue"(that says Undeclared element)?

The second part of this is that Resharper has somethink called Type name completion. It some improved intellisense. Lets say you have no using declaration in your file. Then you type something like ICompar and press CTRL+SPACE. Of cause there will be no suggestions. But with Resharper you can press CTRL+ALT+SPACE and you get suggestions of all classes starting with ICompar even if they are not in using. When you choose one of them the correct using is automatically added for you.

Is there a way to make CodeRush behave this way ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

终遇你 2024-09-09 06:09:28

第一部分

Visual Studio

您提到的默认 VS 机制是使用 Ctrl+Period 或 Shift+Alt+F10 触发的

CodeRush 模板

让我引用 Mark Miller 的话(CodeRush 的首席架构师)对于这一部分:

“CodeRush 模板(就像类固醇上的 VS 代码片段)将根据需要添加命名空间,因此如果您使用模板来创建类、方法、变量、属性、事件和类型引用那么命名空间引用将自动添加,您很少需要使用 VS 功能来添加命名空间。要开始使用模板,我们建议将 CodeRush 培训窗口 (DevExpress | Tool Windows | CodeRush) 停靠在编辑器的一侧。并检查培训窗口中的提示和模板,您可以使用它来生成所需的代码,只需键入窗口中显示的模板,然后使用空格键展开它。”

尝试 v 系列,即m 系列、n 系列和 t 系列。

所以我的意思是:

  • 启动 CodeRush 训练窗口 (DevExpress\Tool Windows\CodeRush)
  • 将其停靠在左侧
  • 返回到编辑器
  • 输入“v”(无引号)
    • 请注意,这是上下文敏感的
      • 当插入符号在类中时尝试此操作。
      • 当插入符号位于方法中时尝试此操作。
  • 现在查看“训练”窗口。
  • 您应该会看到一些关于要输入的其他字符的建议。
  • 输入其中一项建议,然后按空格键。

这就是您对 v 系列模板的介绍。

请随意查看 m 系列、n 系列和 t 系列。

另请注意,当您处于空行时,培训窗口还会提供建议。

社区插件

CodeRush 中没有内置任何内容来提供“添加此类型的使用”功能。

不过,有许多社区插件可以为 CodeRush 添加各种功能。这种可扩展性是 CodeRush 的最佳功能之一。

特别是一个插件 Refactor_Resolve 的功能可能与您所描述的非常接近。

第二部分

我不认为 CodeRush 目前提供任何智能感知增强功能。

对不起

PART I

Visual Studio

The default VS mechanism you mention is tripped using Ctrl+Period or Shift+Alt+F10

CodeRush Templates

Let me quote Mark Miller (Chief architect of CodeRush) for this part:

"CodeRush templates (like VS code snippets on steroids) will add namespaces as needed, so if you use templates to create classes, methods, variables, properties, events, and type references then the namespace references will be added automatically and you'll rarely need to use the VS feature for adding namespaces. To get started with the templates we recommend docking the CodeRush training window (DevExpress | Tool Windows | CodeRush) to the side of the editor and check that training window for tips and templates you can use to generate the code you need. Just type the template as it shows up in the window and expand it using the space bar."

Try the v-series, the m-series, the n-series and the t-series.

So what I mean by this is:

  • Launch the CodeRush training window (DevExpress\Tool Windows\CodeRush)
  • Dock it to the left
  • Back to the editor
  • Type 'v' (no quotes)
    • Careful this is context sensitive
      • Try this whilst the caret is in a class.
      • Try this whilst the caret is in a method.
  • Now look at the Training window.
  • You should see a few suggestions of further characters to type.
  • Type one of the suggestions and then hit space.

That was your introduction to the v-series of templates.

Feel free to check out the m-series, the n-series and the t-series.

Also note that the training window also provides suggestions when you are on a blank line.

Community Plugins

There is nothing built into CodeRush which provides "Add using for this type" functionality.

However there are numerous Community Plugins which add all sorts of functionality to CodeRush. This extensibility is one of the best features of CodeRush.

One plugin in particular Refactor_Resolve has functionality that might come close to what you describe.

PART II

I don't believe there are any intellisense enhancements provided by CodeRush at this time.

Sorry

Oo萌小芽oO 2024-09-09 06:09:28

不是一个答案,但给我最好的穷人垃圾解决方法,以防没有更好的解决方法......是 Ctrl-Home (文件顶部)然后 usl(展开为使用 System.Linq)然后 Ctrl-Minus(回到我们之前的位置 - 当然您可以使用 CR 标记也)。

(我在 CR bugbase 中有一个请求对此进行排序)

Not an answer, but giving my best poor mans crap workaround in case there isnt a better one... is Ctrl-Home (top of file) then usl and <space> (expand to using System.Linq) then Ctrl-Minus(Back to where we were - of course you can use the CR markers too).

(I have a request in the CR bugbase for this to be sorted)

请帮我爱他 2024-09-09 06:09:28

DX 围绕此构建了另一个示例。我希望它能进入 CR 产品,但我想人们不应该抱怨免费插件(无论如何太多)。

DX have built another sample around this. I wish it'd get into the CR product but I guess one shouldn't whine about free plugins (too much anyway).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文