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 242484 - Javacsript Intellisense type information is lost on var when constructed via "new MyLib.Class()"
Summary: Javacsript Intellisense type information is lost on var when constructed via ...
Status: STARTED
Alias: None
Product: javascript
Classification: Unclassified
Component: Editor (show other bugs)
Version: 8.0
Hardware: PC Windows XP
: P3 normal (vote)
Assignee: Petr Pisl
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-03-01 17:05 UTC by NukemBy
Modified: 2014-03-28 08:29 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
ScreenShot - The Global Varialbe is not declared (9.62 KB, image/png)
2014-03-01 19:03 UTC, NukemBy
Details

Note You need to log in before you can comment on or make changes to this bug.
Description NukemBy 2014-03-01 17:05:45 UTC
This is sub-case from  https://netbeans.org/bugzilla/show_bug.cgi?id=242344 (2014-02-26 20:47:23 UTC, #(2.1) ) which, hopefully, can be fixed quicker.

Occurs in Dev (Build 201403010001).
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 

var myLib2 = new function MyLib2() {
    /** 
     * My Class
     * 
     * @constructor
     * @type MyLib2.MyLibClass
     * @returns {MyLib2.MyLibClass}
     */ 
    function MyLibClass() {
        /** @member {string} JsDoc for classMember */
        this.classMember = "member";
    };
    
    // make my class publically accessible
    this.MyLibClass = MyLibClass;

    /**
     * Builder of MyLibClass
     * @returns {MyLib2.MyLibClass}
     */
    this.makeMyLibClass = function () {
        return new MyLibClass();
    };
};

// (1) Intellisense does NOT suppose 'MyLibClass' after myLib2
var objViaNew = new myLib2.MyLibClass();

// (2) Intellisense does NOT suppose 'classMember' after objViaNew
var tmp = objViaNew.classMember;

// (3) Intellisense works CORRECTLY when object is constructed via builder method
var objViaMake = myLib2.makeMyLibClass();
var tmp = objViaMake.classMember;

// (4) Intellisense on instance variable 'objViaNewWithType' works CORRECTLY 
//     when variable from case #1 explicitly annotated with @type.
/** @type MyLib2.MyLibClass */
var objViaNewWithType = new myLib2.MyLibClass();
var tmp = objViaNewWithType.classMember;
Comment 1 NukemBy 2014-03-01 19:03:27 UTC
Created attachment 145697 [details]
ScreenShot - The Global Varialbe is not declared
Comment 2 NukemBy 2014-03-01 19:11:54 UTC
I suppose the root cause for that problem is naming conflict which somehow appears in NetBeans between "this.MyLibClass" and "function MyLibClass". In valid JS these names exist in different contexts and should not intersect, but NetBeans currently fails when name of the variable within 'this' is the same as name of the function. See attached screenshot.

Problem does no occur with following code:

var myLib2 = new function MyLib2() {
    function _MyLibClass() {};
    
    this.MyLibClass = _MyLibClass;
};

or

var myLib2 = new function MyLib2() {
    function MyLibClass() {};
    
    this._MyLibClass = MyLibClass;
};
Comment 3 Petr Pisl 2014-03-28 08:29:18 UTC
Reproducible, I'm going to look at this.