简体   繁体   中英

Documenting javascript in Netbeans for autocompletion/code completion/intellisense

I am using Netbeans 6.9 and 7-Beta on Windows 7. According to Netbeans javascript documentation it should be possible to add documentation to my project and get autocompletion on my classes and functions. The trouble I am having is that I'm using my own class declaration (via a function called Class ) and can't seem to get things working. For example a simple class declaration would look like:

mySubClass = Class(parentClass, {
  memberVariable: null,

  /**
   * @class mySubClass
   * @constructor
   */
  initialize: function(value) {
    this.memberVariable = value;
  },

  /**
   * @class mySubClass
   */
  getMV: function() {
    return this.memberVariable;
  },

  /**
   * @class mySubClass
   */  
  setMV: function(value) {
    this.memberVariable = value;
  }
});

I've tried many variations and placements of the declarations ( @class , @memberOf , etc) but cannot get completion working. For example after,

var testObj = new my

I should be able to get mySubClass by hitting "ctrl+space" and similarly proceed to:

var test = new mySubClass(1);
test.

and get options for getMV and setMV . Is this possible and if so, how do I do it? Thanks.

It should work with @lends (see JSDoc-toolkit CookBook ). It doesn't work in Netbeans 7.2 though (even @type and @link doesn't work).

I had the same problem. Your code could have been simplified, I had to read twice to understand that Class was a custom function of yours, not js syntax..

foo.canvas = function(id) {
  this.clear = function() {};
};
bar = foo.canvas("myCanvas");
bar. <-- here NetBeans doesn't suggest the "clear" function.

It seems the NetBeans doesn't do introspection well in JS. It only seems to work for native and host objects.

Try Komodo Edit, it seems to get this right.

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