We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Should show line number information.
Test case:
let {parseScriptWithLocation, parseModuleWithLocation} = require("shift-parser"); let {tree, locations, comments} = parseScriptWithLocation("2 + 3 /* = 5 */"); console.log(JSON.stringify(locations))
Output = {}
Expected: Can show locations Actual: Shows empty array {}
{}
The text was updated successfully, but these errors were encountered:
That's because it's a WeakMap. That's how WeakMaps work. What are you expecting?
Sorry, something went wrong.
I need to serialize the location information. For each AST node, I need to determine the start and end line number.
You can just stick the location information on the nodes, if you want:
let { tree, locations } = parseScriptWithLocation(`whatever`); function addLocationInformation(node) { node.loc = locations.get(node); for (let field of Object.values(node)) { if (Array.isArray(field)) { field.forEach(addLocationInformation); } else if (typeof field === 'object' && field !== null) { addLocationInformation(field); } } } addLocationInformation(tree); console.log(JSON.stringify(tree));
No branches or pull requests
Should show line number information.
Test case:
Output = {}
Expected: Can show locations
Actual: Shows empty array
{}
The text was updated successfully, but these errors were encountered: