Bug 227489

Summary: AST does not support nested functions
Product: [WebTools] JSDT Reporter: Etienne Pfister <epfister>
Component: GeneralAssignee: Phil Berkland <berkland>
Status: RESOLVED FIXED QA Contact: Phil Berkland <berkland>
Severity: major    
Priority: P3 CC: cbachman, hjzhang, kaloyan
Version: unspecifiedKeywords: contributed
Target Milestone: 3.0 RC1Flags: berkland: pmc_approved? (david_williams)
berkland: pmc_approved? (raghunathan.srinivasan)
berkland: pmc_approved? (naci.dai)
berkland: pmc_approved? (deboer)
berkland: pmc_approved? (neil.hauge)
kaloyan: pmc_approved+
Hardware: All   
OS: All   
Whiteboard: PMC_approved
Attachments:
Description Flags
patch to handle nested functions
none
patch to handle nested functions
none
new patch to handle nested functions bjorn.freeman-benson: iplog+

Description Etienne Pfister CLA 2008-04-17 03:59:25 EDT
Created attachment 96388 [details]
patch to handle nested functions

The AST/Parser can't handle nested functions. The inner function will be represented as an empty statement. For the refactoring support it is essential to get a correct AST of the source code.

Example javascript code:
function outerFunction() {
    function innerFunction(){
    } 
}


... Will be represented as:
function outerFunction() {
	;
}

AST creates an empty statement instead of a nested function.
Comment 1 Etienne Pfister CLA 2008-04-17 04:18:22 EDT
Created attachment 96391 [details]
patch to handle nested functions

new patch to handle nested functions, the old patch was wrong.
Comment 2 Phil Berkland CLA 2008-05-05 17:39:51 EDT
This patch will not work as is because MethodDeclaration has been renamed to FunctionDeclaration.  
Comment 3 Etienne Pfister CLA 2008-05-06 12:07:22 EDT
Hi Phil,

thanks for the information, I have applied the mentioned refactoring scripts to our source. I have seen that the class org.eclipse.wst.jsdt.internal.compiler.ast.MethodDeclaration has still the MethodDeclaration name instead of FunctionDeclaration... just for your information.

The new patch is attached.
Comment 4 Etienne Pfister CLA 2008-05-06 12:09:02 EDT
Created attachment 98875 [details]
new patch to handle nested functions
Comment 5 Phil Berkland CLA 2008-05-09 16:16:29 EDT
This patch looks good.
Comment 6 Kaloyan Raev CLA 2008-05-10 03:52:47 EDT
The issue looks to be considerable to be fixed in RC. Patch looks quite simple.

But, like in bug 231122, a few book-keeping details before approving:
  - PMC in Whiteboard
  - Helen to CC
  - set Target Milestone
  - consider the "contribution" keyword if Etienne is not a committer
Comment 7 Kaloyan Raev CLA 2008-05-10 05:42:34 EDT
Thanks for the changes, Etienne. However, my notes were addressed to Phil since they are his responsibilities as component lead :-)

Still, waiting Phil to set the Target Milestone. 
Comment 8 Kaloyan Raev CLA 2008-05-13 06:12:01 EDT
Approved
Comment 9 Phil Berkland CLA 2008-05-13 12:14:14 EDT
Applied patches.  Thank you for your continuing contributions.