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 162305 - code completion based on JSDoc is broken
Summary: code completion based on JSDoc is broken
Status: RESOLVED DUPLICATE of bug 215764
Alias: None
Product: javascript
Classification: Unclassified
Component: Editor (show other bugs)
Version: 6.x
Hardware: PC Windows XP
: P3 blocker with 2 votes (vote)
Assignee: Martin Fousek
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-04-09 13:49 UTC by benf
Modified: 2012-09-24 08:18 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 benf 2009-04-09 13:49:57 UTC
(also occurs in 6.7 M3, but used to work in 6.5)

Although "@type" of a function is defined in JSDoc, the function doesn't show up in the appropriate auto complete list.
Also already in 6.5 auto-complete didn't work for functions of the same class: "this.getFoo()." would not display Foo's
functions. From the outside it works in 6.5, but no longer in 6.7

I'll attach an example with more detailed explanations...
Comment 1 benf 2009-04-09 13:55:42 UTC
here's an example... comment in the last line explains what happens

-----------------------
/**
 * @constructor
 */
var Foo = function () {

    /**
     * @type Bar
     */
    this.getBar = function () {
        return new Bar("fooo");
    };
}

/**
 * @constructor
 * @param {String} input
 */
var Bar = function (input) {
    this.bar = input + "baaaaaaaaaaar";

    /**
     * @type String
     */
    this.getOutput = function () {
        return this.bar;
    }
}

var f = new Foo();
f.getBar().   //completion doesn't show getOutput()
Comment 2 Marek Fukala 2009-04-17 14:20:55 UTC
The example works fine for me (f.getBar().| + CC offers getOutput()), can you verify on latest build?
Comment 3 benf 2009-04-21 09:43:32 UTC
tried it again on netbeans-trunk-nightly-200904171401-ml-windows.exe

still doesn't show getOutput()

f.getBar().| + CC offers a very long list starting with "Some results omitted [...]"
maybe the time it looks for possible results is too short or my pc is too slow; just a thought i had...
Comment 4 Marek Fukala 2009-04-21 10:44:24 UTC
getOutput() is not first in the list, but If you narrow the query by typing getO, you should be able to see the item.
Can you please verify that please? If not, reopen again. 
Comment 5 Marek Fukala 2009-04-21 10:52:15 UTC
OTOH you are right that the getOutput() method is not shown as a member of the Bar class at the top of the completion
list above the line separator, it is just listed as a function without context.

Comment 6 benf 2009-04-21 11:52:24 UTC
sorry, i wasn't too clear about where i looked for it in the list; but that's exactly what i meant.
If Bar's methods and attributes are not shown at the top, above the line, the whole JsDoc and CC feature is rendered
quite useless and Netbean's JS-editor is just another code-highlighter.
Comment 7 Marek Fukala 2009-04-21 14:30:38 UTC
fixed in web-main#89bcbda9ebe8.

The problem looks like introduced by the parsig.api migration where some bug in indexing suppor was fixed and revealed a
"typo" in the javascript code.
Comment 8 Quality Engineering 2009-04-22 08:40:15 UTC
Integrated into 'main-golden', will be available in build *200904220201* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/89bcbda9ebe8
User: Marek Fukala <mfukala@netbeans.org>
Log: #162305 - code completion based on JSDoc is broken
Comment 9 martin_zmrhal 2009-10-27 16:00:24 UTC
verified

Product Version: NetBeans IDE Dev (Build 200910270201)
Java: 1.6.0_16; Java HotSpot(TM) Client VM 14.2-b01
System: Linux version 2.6.28-11-generic running on i386; UTF-8; en_US (nb)
Comment 10 vitrilo 2009-11-27 05:00:35 UTC
Auto-complete didn't work for functions of the same class:

/**
 * @constructor
 */
var Foo = function () {

    /**
     * @type Bar
     */
    this.getBar = function () {
        return new Bar("fooo");
    };
    /**
     * @type Foo
     */
    this.getFoo = function () {
        return new Foo();
    };
    this.test = function () {
        this.getBar().  //completion doesn't show getOutput()
    };
    this.test2 = function () {
        this.getFoo(). //completion doesn't show getBar() and other methods
    };
}

/**
 * @constructor
 * @param {String} input
 */
var Bar = function (input) {
    this.bar = input + "baaaaaaaaaaar";

    /**
     * @type String
     */
    this.getOutput = function () {
        return this.bar;
    }
}

Tested on NetBeans IDE 6.7.1 and NetBeans IDE Dev (Build 200911241400);
Java: 1.6.0_10;
Windows XP SP2;
Comment 11 Petr Pisl 2010-02-15 06:20:38 UTC
I will look at this.
Comment 12 Petr Pisl 2010-05-19 13:52:15 UTC
For the comment from vitrilo. The code completion now shows function in both cases, but there are not at the top.
Comment 13 vitrilo 2010-05-28 07:23:55 UTC
Than you Petr Pisl for interesting this bug.
I try to clarify a little.

STR 1:
1. Create new "Web Application" project.
2. Create new file inside project with type "Javascript File" and any name (like "newjavascript.js").
3. Paste source code of my comment #10 into created js file.
4. Fix code to be fully valid.
5. Start typing in line this.getBar() 
- pop-up with JSDoc opened for getBar() method with type=Bar (Okay!)
6. Type dot after this.getBar() to get Bar class  methods 
- pop-up opened with "Some results omitted. Type more to narrow search." (Bug)

Note: these pop-up contains all method from all objects in project, and if project are very small - yep  - you will see required in list bottom:
(In reply to comment #12)
> For the comment from vitrilo. The code completion now shows function in both
> cases, but there are not at the top.
- Yep, this is true

STR 2:
1-4. All steps the same, except, you already have project with BIG number of .js files with BIG number of .js classes.
5. Start typing in line this.getBar() 
- pop-up with JSDoc opened for getBar method with type=Bar (Okay!)
6. Type dot after this.getBar() to get Bar class methods
- pop-up opened with "Some results omitted. Type more to narrow search." (Bug)

Note: You will NOT see required methods in the list, because this pop-up tried to show top of all methods of all objects inside a project.

In real live - I have project with 25k lines of js code written in OOP-style, so I reproduced STR 2 in 99% of cases. 

Tested on NetBeans IDE 6.9 RC1 and NetBeans IDE Dev (Build 201005270001);
Java: 1.6.0_10;
Windows XP SP2;
Comment 14 133794m3r 2011-05-13 01:19:51 UTC
JSDOC is NOT working in netbeans 6.10. I've even set it up _exactly_ like jsdoc requires, but there is no support for it. 

The following code causes no completition to be shown.

/**
 *Rounding with precision
 *
 *Allows for one to round a number with decimal precision in mind if they so wish.
 *
 *@param    n   the number to be rounded
 *@param    x   [optional]the precision for the rounding after the decimal
 *@return   the rounded value
 */
function round(n,x){
    var y=0;
    if(x!==undefined){
        y=n.toFixed(x);
    }
    n=Math.round(n);
    if(y!==n&&x!==undefined){
        return y;
    }
    else{
        return n;
    }
}

When typing r in any other documents, there is no completion at all. Even typing rand( doesn't cause it to be called forth. Since it is defined as it should be, there is nothing going on here. Netbeans is just ignoring it.
Comment 15 Martin Fousek 2012-09-24 08:18:58 UTC
In the new JS editor the first case is in the completion as well as in the last case documentation is correctly shown. Anyway the return types from functions aren't still guessed. But because this issue become really obfuscated, I'm marking this issue as duplicate of the newer one - the "guess function return type" one.

*** This bug has been marked as a duplicate of bug 215764 ***