How does the JSDT parser differentiates between a function and a constructor [message #1728612] |
Tue, 05 April 2016 20:58 |
Laleh m Messages: 9 Registered: May 2013 |
Junior Member |
|
|
I am trying to use JSDT to visit ASTs of a javascript project.
How does the parser differentiates between a function and a constructor.
In other words, how does FunctionDeclaration.setConstructor (true) is being called?
I tried to find who calls this method and I reach to
org.eclipse.wst.jsdt.core.infer.InferEngine.visit(IFunctionDeclaration) but it gets a bit confusing from here.
Theoretically, is it true that if a javascript function is initializing some properties then the isConstrucotr will be set to "true"? This means that the parser traverses the body of a javascript function two times and then based on some patterns in the body, the parser infers that the function is indeed a Constructor, is it true?
For example, in the following examples MyFunc1 isConstructor is "true" but MyFunc2 isConstructor is "false".
function MyFunc1(){
this.a=4;
this.b=5;
}
function MyFunc2(){
var p=this.a+this.b;
}
Thank you very much
|
|
|
Powered by
FUDForum. Page generated in 0.03443 seconds