Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » ServerTools (WTP) » JSDT VariableDeclarationExpression in For-Statement drops "var"(I suspect a bug in the javascript parser.)
JSDT VariableDeclarationExpression in For-Statement drops "var" [message #1582119] Sat, 24 January 2015 12:20
Pete Pentel is currently offline Pete PentelFriend
Messages: 1
Registered: April 2012
Junior Member
I suspect a bug in the way "for"-statements are handled:

The statement "for(var i = 0; i < 5; i++);" gets parsed to "for ( i=0; i < 5; i++) ;" - i.e. the variable declaration is dropped and only the VariableDeclarationExpression "i=0" remains. The two are semantically different.

Any ideas?

Example code:
ASTParser parser = ASTParser.newParser(org.eclipse.wst.jsdt.core.dom.AST.JLS3);
parser.setSource("for(var i = 0; i < 5; i++);".toCharArray());
JavaScriptUnit cu = (JavaScriptUnit) parser.createAST(null);
Statement statement = (Statement)cu.statements().get(0);
System.out.println(statement);


This prints "for ( i=0; i < 5; i++) ;" not "for(var i = 0; i < 5; i++);".
(Tried with the luna release.)
Previous Topic:fetching database using web service
Next Topic:How to Parse JSP
Goto Forum:
  


Current Time: Sat Apr 27 01:23:40 GMT 2024

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

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

Back to the top