简体   繁体   中英

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. 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. Unfortunately, I can't seem to get it to work.

As an example, suppose the file module.js contains the following code:

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:

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. 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?

  1. You have an extra closing parenthesis in your example of module.js, so it can be a problem.
  2. As I understand, module.intellisense.js is not apply to module.js itself. But other files, that will use module.js works fine.
  3. Changes in module.intellisense.js are not apply immediately, even if use Ctrl+Shift+J - need some time or an actions with file.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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