Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » ServerTools (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 #1728612] Tue, 05 April 2016 20:58
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:I don't see glassfish server on eclipse
Next Topic:JSDT set up build Environment occur error
Goto Forum:
  


Current Time: Sun Dec 08 12:35:31 GMT 2024

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

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

Back to the top