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:BUG? XML Validator doesn't follow redirects for schemaLocation
Next Topic:Getting http request parameters in a ContentProposalProvider
Goto Forum:
  


Current Time: Mon Sep 24 03:24:20 GMT 2018

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

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

Back to the top