R# 插件测试:如何在名称中用括号指定上下文操作

R# Plugin test: How to specify context action with bracket in name

我创建了一个复合上下文操作,其中 returns 具有以下文本的几个意图:

现在我正在尝试通过测试来涵盖此操作。我按照指南做了所有事情,但我无法使用 caret 符号来识别第一个动作。

我尝试了以下选项:

他们的笔记有效:(

如果我对 Second Action 做同样的事情,一切都很好。问题可能与括号有关。

我不想更改操作的名称。您能否建议如何用括号指定操作?

谢谢!

更新

我找到了以下解决方法:

  1. 在数据文件中指定操作的别名:{caret:TagAction}.
  2. 覆盖SelectItem方法并调整属性

    protected override IBulbAction SelectItem(SetFrozenAttributeAction contextAction, string attribute, ITextControl textControl)
    {
      if (attribute == "TagAction") attribute = "[Tag] Action";
      return base.SelectItem(contextAction, attribute, textControl);
    }
    

如果你知道更好的方法 - 建议:)

是的,就是括号。我不知道为什么,但是当它遇到左大括号 { 时,它不会读取到右大括号 },而是读取一组它认为是 [=30= 的字符],然后在遇到第一个无效字符时停止。有效字符为 char.IsLetterchar.IsDigit$(), -. , /, \。但不是 [] - 所以你的 {caret:[Tag] Action} 只会读取 {caret: 然后停止。

您的解决方法似乎是最好的选择!