Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 439003

Summary: [esprima] Esprima parser recovery fails before for loop
Product: [ECD] Orion Reporter: Ashwin Baliga <ashbaliga>
Component: JS ToolsAssignee: Michael Rennie <Michael_Rennie>
Status: RESOLVED WORKSFORME QA Contact:
Severity: normal    
Priority: P3 CC: ken_walker
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows 7   
Whiteboard:

Description Ashwin Baliga CLA 2014-07-07 05:16:56 EDT
In the following JavaScript file, code assist works and shows number properties correctly:

var abc=20;
abc.|  <-- code assist here
while(true)
{
}

But in the following case, number properties are not shown:

var abc=20;
abc.|  <-- code assist here
for(;;)
{
}
Comment 1 Michael Rennie CLA 2014-07-07 11:05:57 EDT
The problem is that we are completely failing to recover in this case.
 
> var abc=20;
> abc.|  <-- code assist here
> while(true)
> {
> }

In this case we get an AST rooted as:

VariableDeclaration
ExpressionStatement
WhileStatement

OK - this is the expected AST

> But in the following case, number properties are not shown:
> 
> var abc=20;
> abc.|  <-- code assist here
> for(;;)
> {
> }

In this case we get an AST rooted as:

VariableDeclaration
ExpressionStatement
ExpressionStatement

WRONG - third root should be ForStatement, there are also a bunch of (what look like) cascading syntax errors:

 Syntax error on token ';', delete this token.
 Syntax error on token ')', delete this token.
 Syntax error on token '{', delete this token.
Comment 2 Michael Rennie CLA 2014-07-07 11:35:21 EDT
(In reply to Michael Rennie from comment #1)
> The problem is that we are completely failing to recover in this case.
>  
> > var abc=20;
> > abc.|  <-- code assist here
> > while(true)
> > {
> > }
> 
> In this case we get an AST rooted as:
> 
> VariableDeclaration
> ExpressionStatement
> WhileStatement
> 
> OK - this is the expected AST

This is actually the 'no errors' AST, I grabbed the shot of it just prior to the re-parse.

The actual rooted AST for the while-case is:

VariableDeclaration
ExpressionStatement
  CallExpression
ExpressionStatement
Comment 3 Michael Rennie CLA 2016-04-21 11:51:33 EDT
Now that we use Acorn as our base parser this is working as expected.

Closing worksforme.