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
i was only able to locate the "start" via node.token.position, but figuring out the "end" is not trivial as far as I know
The text was updated successfully, but these errors were encountered:
actually here is a workaround
const tokens = tokenize(code); const ast = parse(tokens); function decoratePosition(node, end) { node.loc = { start: node.token.position || 0, end, }; node.children.forEach((child, i) => { const nextSibling = node.children[i + 1]; decoratePosition( child, nextSibling && nextSibling.token && 'position' in nextSibling.token ? nextSibling.token.position - (nextSibling.token.preceding || []) .reduce((s, n) => s + (n.data || '').length, 0) : end ); }); } decoratePosition(ast, code.length);
Sorry, something went wrong.
No branches or pull requests
i was only able to locate the "start" via node.token.position, but figuring out the "end" is not trivial as far as I know
The text was updated successfully, but these errors were encountered: