titusjan/astviewer

Node positions not ordered

titusjan opened this issue · 0 comments

When traversing the abstract syntax tree nodes in depth first order, the node position (being the lineno and col_offset attributes) are not always encountered in increasing order. For example decorators occur after their function in the tree but before their function in the source code. Also dictionary keys and values nodes are not in order. More examples can be found in testprogs/invalid_highlights.py

All this can lead to invalid highlighting in the tree. Fixing this would require node-type specific knowledge for the different AST node types. This is low-priority. At the moment only decorator nodes are handled as a special case.