Bug 227489 - AST does not support nested functions
Summary: AST does not support nested functions
Status: RESOLVED FIXED
Alias: None
Product: JSDT
Classification: WebTools
Component: General (show other bugs)
Version: unspecified   Edit
Hardware: All All
: P3 major (vote)
Target Milestone: 3.0 RC1   Edit
Assignee: Phil Berkland CLA
QA Contact: Phil Berkland CLA
URL:
Whiteboard: PMC_approved
Keywords: contributed
Depends on:
Blocks:
 
Reported: 2008-04-17 03:59 EDT by Etienne Pfister CLA
Modified: 2010-03-03 11:17 EST (History)
3 users (show)

See Also:
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+


Attachments
patch to handle nested functions (47 bytes, patch)
2008-04-17 03:59 EDT, Etienne Pfister CLA
no flags Details | Diff
patch to handle nested functions (2.80 KB, patch)
2008-04-17 04:18 EDT, Etienne Pfister CLA
no flags Details | Diff
new patch to handle nested functions (2.76 KB, patch)
2008-05-06 12:09 EDT, Etienne Pfister CLA
bjorn.freeman-benson: iplog+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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.