millermedeiros / rocambole

Recursively walk and transform EcmaScript AST
171 stars 12 forks source link

deprecate: token.before(), token.after(), token.remove(), node.getTokens() #1

Closed millermedeiros closed 11 years ago

millermedeiros commented 11 years ago

too much responsibility, these tasks are outside the scope of the project, it would be better to keep just the special properties and leave this logic to a separate library (imagine something like jQuery but for AST manipulation). If we keep adding more methods it will only get worse.

I think we should keep the node.toString() since it is very useful and it reduces the bureaucracy.

millermedeiros commented 11 years ago

even if we decide to keep this kind of feature I think we should implement it similar to jQuery (create a new kind of object that augments tokens/nodes), maybe rocambole.wrap(node) or just rocambole(node).

millermedeiros commented 11 years ago

I moved the methods to the esformatter repo: https://github.com/millermedeiros/esformatter/blob/master/lib/tokenHelpers.js - maybe will break them into a separate project or move back to rocambole, still unsure.

sindresorhus commented 10 years ago

Those methods are very useful. Would be nice to have the rocambole-manipulate lib or something.

millermedeiros commented 10 years ago

I created a rocambole-token module and I'm creating a rocambole-ast repository as well.

I added the properties prev and next to the tokens and nodes so that should be enough to traverse and get all the tokens from the node.

on the rocambole-token repository I have methods to search, remove and insert tokens.

sindresorhus commented 10 years ago

Oh, i didn't notice. That is useful :)