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 156102 - Navigator does not recognize fields of an object, which are declared via the object's prototype in JavaScript source files.
Summary: Navigator does not recognize fields of an object, which are declared via the ...
Status: VERIFIED FIXED
Alias: None
Product: javascript
Classification: Unclassified
Component: Editor (show other bugs)
Version: 6.x
Hardware: All All
: P2 blocker (vote)
Assignee: Marek Fukala
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-12-27 20:18 UTC by shreyder
Modified: 2011-12-13 07:35 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description shreyder 2008-12-27 20:18:28 UTC
The navigator does not recognize fields of an object, which are declared via the object's prototype in JavaScript source
files. However, it does recognize functions, which are declared via the object's prototype.

Example:

function AnObject() {
    this.fieldA = "fieldA";
    this.functionA = function() {return "functionA"};
}

AnObject.prototype.fieldB = "fieldB";

AnObject.prototype.functionB = function() {return "functionB"};

The navigator will list the constructor, fieldA, functionA and functionB, but not fieldB.
Comment 1 Marek Fukala 2009-03-09 15:37:49 UTC
The same problem applies to code completion. Fields declared via the object's prototype are not visible.
Comment 2 Marek Fukala 2009-03-09 17:45:55 UTC
A bug in JsAnalyzer.AnalysisResult.visit(Node) - the prototyped fields are not supported.
A piece of the AST with the prototyped field follows:

 133:EXPR_RESULT[155,208]<655b5671>
        35:SETPROP[155,208]<8cd9095>
            33:GETPROP[155,164]<1f2346b7>
                39:NAME("AnObject")[146,154]<4072dd9>
                41:STRING("prototype")[155,164]<5cea9004>
            41:STRING("functionB")[165,174]<3a543470>
            108:FUNCTION[177,208]<4dd5e29d>
                128:BLOCK[188,207]<6ee4b24e>
                    4:RETURN[189,207]<103bbd00>
                        41:STRING("functionB")[196,207]<295c7163>
Comment 3 Marek Fukala 2009-03-09 17:50:26 UTC
Wrong example :-(. Here is the correct part:

 133:EXPR_RESULT[116,143]<2bb7e2f7>
        35:SETPROP[116,143]<4b317e13>
            33:GETPROP[116,125]<7cef8743>
                39:NAME("AnObject")[107,115]<350f1a7>
                41:STRING("prototype")[116,125]<54c17718>
            41:STRING("fieldB")[126,132]<73ae56bc>
            41:STRING("fieldB")[135,143]<7cc2fbf>
Comment 4 Marek Fukala 2009-03-10 15:49:38 UTC
fixed 

changeset:   119929:94fabcabe9b3
user:        Marek Fukala <mfukala@netbeans.org>
date:        Tue Mar 10 15:47:51 2009 +0100
summary:     #156102 - Navigator does not recognize fields of an object, which are declared via the object's prototype
in JavaScript source files.
Comment 5 Quality Engineering 2009-03-17 08:37:29 UTC
Integrated into 'main-golden', will be available in build *200903170201* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/94fabcabe9b3
User: Marek Fukala <mfukala@netbeans.org>
Log: #156102 - Navigator does not recognize fields of an object, which are declared via the object's prototype in JavaScript source files.
Comment 6 Vladimir Riha 2011-12-13 07:35:10 UTC
v.