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

Bug 490645

Summary: [acorn] Investigate disabling sourceFile and directSourceFile parser options
Product: [ECD] Orion Reporter: Michael Rennie <Michael_Rennie>
Component: JS ToolsAssignee: Olivier Thomann <Olivier_Thomann>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: Olivier_Thomann
Version: 12.0   
Target Milestone: 12.0   
Hardware: All   
OS: All   
Whiteboard:

Description Michael Rennie CLA 2016-03-29 18:25:26 EDT
By default we have turned on the sourceFile and directSourceFile parser options, which are used to attach source file infos to each loc object and ast node respectively.

Since we rarely, if ever use the loc objects, we should disable the sourceFile option.

The directSourceFile option should be turned off as well since it tags every single AST node with source infos. To make sure our AST has the source infos, we should tag only the Program node with the directSourceFile object - we can do this in our AST plugin's postParse hook. 

These two changes should shrink the average AST size considerably.
Comment 1 Olivier Thomann CLA 2016-03-29 21:51:06 EDT
The problem is that some other postParse calls can expect the ast.sourceFile property to be set. So if we set it inside the postParse of the ast tern plugin, we cannot garantee to be the first plugin to be called. If we can, then we can do that. Otherwise we can also change the acorn call to set the sourceFile only on the Program node.
I found that the html plugin expects that property to be set to check if the file is a html file. We can discuss that tomorrow.
Comment 2 Olivier Thomann CLA 2016-03-30 11:57:48 EDT
It looks like tern is using the sourceFile object on each node to store some information.
So the best I could do was to reduce the footprint of that object.
Delivered the change.