Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Eclipse Web Tools Platform Project (WTP) » How does the JSDT parser differentiates between a function and a constructor(JSDT- setConstructor (true))
How does the JSDT parser differentiates between a function and a constructor [message #1728610] Tue, 05 April 2016 20:47
Laleh m is currently offline Laleh mFriend
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
Previous Topic:What Eclipse did to tomcat7 to make the performance more than double
Next Topic:Weblogic Server 12c (12.1.3) will not start up -- no progress, always shows "Starting..."
Goto Forum:
  


Current Time: Sat Nov 11 07:53:05 GMT 2023

Powered by FUDForum. Page generated in 0.01851 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top