简体   繁体   English

将Visual Studio 2012 JavaScript智能感知标记移动到单独的文件

[英]Moving Visual Studio 2012 JavaScript Intellisense Markup to Separate File

I love the intellisense feature of Visual Studio, including the ability to generate my own XML markup for the methods I create. 我喜欢Visual Studio的intellisense功能,包括为我创建的方法生成自己的XML标记的能力。 However, sometimes the comments actually get in the way of seeing what I'm doing (especially when the method is a few lines long and the intellisense for it is three or four times longer than the code itself!) 但是,有时这些注释实际上会妨碍我看到我正在做的事情(特别是当方法长达几行时,它的智能感知比代码本身长三到四倍!)

Under Visual Studio 2012, it should be possible to move the intellisense markup to a separate file, adding .intellisense.js to the end of the file name and placing the files in the same directory. 在Visual Studio 2012下,应该可以将intellisense标记移动到单独的文件中,将.intellisense.js添加到文件名的末尾并将文件放在同一目录中。 Unfortunately, I can't seem to get it to work. 不幸的是,我似乎无法让它发挥作用。

As an example, suppose the file module.js contains the following code: 例如,假设文件module.js包含以下代码:

var module = (function (my) {
    /// <summary>Description of the module</summary>

    my.action = function(doThis) {
        /// <summary>Take an action</summary>
        /// <param type="String">Do this action</param>
        /// <returns type="String" />
        return doThis.toLowerCase();
    }

    return my;
}(module || {}));

I've tried creating a file in the same directory called module.intellisense.js and moving the XML comments from module.js into here: 我尝试在名为module.intellisense.js的同一目录中创建一个文件,并将来自module.js的XML注释module.js这里:

intellisense.annotate(module, {
    'action': function() {
        /// <summary>Take an action</summary>
        /// <param type="String">Do this action</param>
        /// <returns type="String" />
    }
});

intellisense.annotate(window, {
    'module': function() {
        /// <summary>Description of the module</summary>
    }
});

After saving the files, I hit Ctrl Shift J to force the intellisense to update, then give it a moment to think. 保存文件后,我按Ctrl Shift J强制智能感知更新,然后给它一点思考。 Afterward, when I type module.action( , I get no intellisense assistance. What needs to be done to make functional, custom external-file JavaScript intellisense in Visual Studio 2012? 之后,当我输入module.action(我没有得到intellisense帮助。 在Visual Studio 2012中需要做些什么来制作功能性的自定义外部文件JavaScript智能感知?

  1. You have an extra closing parenthesis in your example of module.js, so it can be a problem. 你的module.js示例中有一个额外的右括号,所以它可能是个问题。
  2. As I understand, module.intellisense.js is not apply to module.js itself. 据我了解,module.intellisense.js不适用于module.js本身。 But other files, that will use module.js works fine. 但其他文件,将使用module.js工作正常。
  3. Changes in module.intellisense.js are not apply immediately, even if use Ctrl+Shift+J - need some time or an actions with file. module.intellisense.js中的更改不会立即应用,即使使用Ctrl + Shift + J - 需要一些时间或文件操作。

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

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