Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 348319

Summary: [content assist] function overloading not supported
Product: [WebTools] JSDT Reporter: Philippe Marschall <philippe.marschall>
Component: GeneralAssignee: Project Inbox <jsdt.javascript-inbox>
Status: NEW --- QA Contact: Chris Jaun <cmjaun>
Severity: enhancement    
Priority: P3    
Version: 3.3   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:
Attachments:
Description Flags
function overlading using JSDoc
none
function overloading repeating the function none

Description Philippe Marschall CLA 2011-06-05 07:37:39 EDT
While JavaScript does not support overloading a function like Java it is possible to call a function with different numbers of arguments or types. The function can then perform introspection and decide what to do. Several JavaScript libraries use this to implement setters and getters. If a function is called without and argument it acts as a getter. If it's called with an argument it acts as a setter.

JSDoc has a native way to support this http://code.google.com/p/jsdoc-toolkit/issues/detail?id=157 an other option imaginable would be to simply repeat the function several times.

Steps to Reproduce:
1. create a JavaScript library with one of the attached files
2. type jQuery("a") and hit Ctrl+Space

Expected Behavior
You get two "text" functions in the completion proposal, one with an argument, one without.

Actual Behavior
You only get one "text" function in the completion proposal.
Comment 1 Philippe Marschall CLA 2011-06-05 07:38:37 EDT
Created attachment 197356 [details]
function overlading using JSDoc
Comment 2 Philippe Marschall CLA 2011-06-05 07:39:18 EDT
Created attachment 197357 [details]
function overloading repeating the function