javalang icon indicating copy to clipboard operation
javalang copied to clipboard

Include position information in all AST nodes

Open c2nes opened this issue 10 years ago • 5 comments

The Node base class should include a 'position' attribute. This should be populated with position information for all nodes types in the parser. The position should be copied from the first token associated with each AST node.

c2nes avatar Jun 06 '14 01:06 c2nes

Currently the information only seems to be there for Field and Method declarations. Any particular reason why:

  • the position information is private?
  • the other nodes don't have the position information?

ramakrishna-n avatar Nov 17 '15 07:11 ramakrishna-n

Another user needed the position information in a couple of limited cases. I filed this issue to follow up that change with more complete support. I would absolutely like this information to be available on all AST nodes as a public property, but simply haven't taken the time to implement it yet.

c2nes avatar Nov 29 '15 18:11 c2nes

Hey Guys, is there a way to easily get the position from MethodDeclarations ? I've been trying to access this and can only acess via tokenizer, but im using filter ClassDeclarations to get methods.

Any tips for me ? Thank you very much!

joaozenos avatar Jul 23 '16 18:07 joaozenos

I think the position value for AST nodes is vital information, especially in AST analyses. Is there any progress on this issue?

emadpres avatar Jan 31 '20 12:01 emadpres

Thank you for a helpful tools for extracting AST nodes, but currently the nodes having position excluede some that are Assignment,BinaryOperation,ReferenceType and so on, these nodes are significant to figure out the preoblems.Hoping to the next work including them.

xjp08 avatar Mar 31 '23 13:03 xjp08