This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 190645 - JavaScript annotations should drive code outline and autocomplete.
Summary: JavaScript annotations should drive code outline and autocomplete.
Status: NEW
Alias: None
Product: javascript
Classification: Unclassified
Component: Editor (show other bugs)
Version: 8.2
Hardware: PC Mac OS X
: P2 normal with 1 vote (vote)
Assignee: Petr Pisl
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-09-28 15:16 UTC by davidfoley
Modified: 2017-06-26 21:44 UTC (History)
1 user (show)

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description davidfoley 2010-09-28 15:16:49 UTC
I often use factory methods to create objects or define prototype properties. In the example below I'm utilising an extension to Function.prototype that copies any object properties to any constructors prototype:

    Example.implement
    (
        {
            /**
             * @private
             * A private field
             * @type {String}
             */
            property: null
            
            /**
             * Invoke a method
             * @return {void}
             */
        ,   method: function () 
            {
                return;
            }
        }
    );
    
    /**
     * Create a new Example
     * @constructor
     */
    function Example () 
    {
        
    };

Netbeans does NOT pick up on any properties when objects are defined this way, even if I annotate property and method with @class, @member, @memberOf or @namespace. There is no way at all to associate properties with constructor prototypes without explicitly implementing in the classic JavaScript manner:

    /**
     * A public flag variable
     * @type {Boolean}
     */    
    Example.prototype.flag= null

or by assigning an object to prototype

    Example.prototype=
    {
        /**
          * A name property
          * @type {String}
          */
         name: null
    }

or by defining within a constructor

    function Example (value)
    {
        /**
          * @private
          * @type {Number}
          */    
         this.value= value
    };

There should be some way to inform the IDE that a property is a member of a class, without having to write code in a certain way. I suggest then, the use of @member to inform the IDE, or even better, for Netbeans to provide a way to register a factory method or implementation idiom that it can infer from.

In a nutshell- annotations should drive how the IDE interprets an object and its members- and these annotations should be entirely decoupled from, or override, inferences made from programming style.
Comment 1 Petr Pisl 2010-10-25 09:26:03 UTC
The same approach we have in PHP. Should be doable.