Code Completion and Type Analysis

JavaScript code completion gives you a choice of the IDE's built-in JavaScript core classes to insert into your code. For example, you can write

    x = "foo";      y = x;      y.  

and code completion will show you the methods available for JavaScript strings. Code completion works with all the literal types in JavaScript. The type analysis and code completion machinery also knows about prototype style classes (regular functions only) and the new operator for constructing them.

NetBeans IDE consults type parameters for function parameters and return types (@type, @param). These types are shown in code completion: in the list, in the documentation, and in parameter hints (Ctrl-P). Return types are also shown in the code completion dialog after the function name, separated by a colon.

If you mark a method with @deprecated, it is struck through in the navigator and in code completion calls to this method. The accompanying deprecated description is shown in a separate section in the code completion documentation with a highlighted background.

NetBeans IDE can also determine the return type for many functions. This function is essential for JSQuery support.

Documentation

Code completion shows the API documentation for both the core javascript APIs and the DOM APIs. You can also view documentation for your own functions. Ctrl-pointing at calls also shows documentation (as a tooltip).

Embedded Completion

Code completion on element IDs in the HTML works for the Prototype.js $("...") function. To see code completion on element IDs, press Ctrl-Space within the quotation marks. For example, if you add variable = $("f|") and press Ctrl-Space with the cursor (|) immediately after the f, code completion shows all HTML element IDs in the document that start with f.

JSDoc Support

If you annotate a method with @private, it shows up in the navigator with a lock icon. If you annotate a function with @constructor it is shown as a constructor (and included in code completion after the "new" keyword), and you can use @class and @namespace to explicitly assign functions to given classes (though the type analyzer can often assign these functions automatically). Functions marked @ignore do not show up in code completion. However, such functions are included in the index and can be used in a Go To Declaration.

Basic File Inclusion Filtering

Code completion in HTML only includes code from referenced JavaScript files. Consider a project in which the file foo.js defines the function foo(), and the file bar.js defines the function bar(). If the file hello.html includes only <script src="bar.js"></script>, only the bar() function is shown in code completion for hello.html.


Legal Notices