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

Bug 329803

Summary: Function literal with attributes assigned using "this." is not inferred as a type like regular functions are
Product: [WebTools] JSDT Reporter: Chris Jaun <cmjaun>
Component: GeneralAssignee: Chris Jaun <cmjaun>
Status: RESOLVED FIXED QA Contact: Nitin Dahyabhai <thatnitind>
Severity: normal    
Priority: P3 Flags: thatnitind: review+
Version: 3.2.2   
Target Milestone: 3.2.3   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
patch none

Description Chris Jaun CLA 2010-11-09 10:04:43 EST
I have a function in a JS file:

var mortCal = function (homeCost, downPayment, interestRate, term) {
    this.homeCost = homeCost;
    this.downPayment = downPayment;
    this.interestRate = interestRate;
    this.term = term;
};


I try to do:
var mc = new mort*

I attempt content assist where the * is. I would expect to see my inferred type mortCal as a proposal, but I do not.

If I change the function to the following then it works correctly:
function mortCal(homeCost, downPayment, interestRate, term) {
    this.homeCost = homeCost;
    this.downPayment = downPayment;
    this.interestRate = interestRate;
    this.term = term;
};
Comment 1 Chris Jaun CLA 2010-11-09 10:08:08 EST
Created attachment 182719 [details]
patch
Comment 2 Chris Jaun CLA 2010-11-09 10:09:25 EST
Patch stores a potential function name in the AbstractMethodDeclaration object if one can be determined during the inference step.

If it is determined that the function has no selector and one is needed then the potential name is returned if one exists.
Comment 3 Chris Jaun CLA 2010-11-09 11:24:49 EST
Checked into 3.2.3 and HEAD.