summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSylvain Thénault <sylvain.thenault@logilab.fr>2011-06-16 19:13:15 +0200
committerSylvain Thénault <sylvain.thenault@logilab.fr>2011-06-16 19:13:15 +0200
commit9d8800ca5703f364518240016aaed8e5434b2472 (patch)
tree3df0b337f34920f3064980341cdadf4b60e5d93c
parentdb7ea8451a98b437ee635e99d83944f2a9d3acc2 (diff)
downloadastroid-git-9d8800ca5703f364518240016aaed8e5434b2472.tar.gz
closes #69217: please add column offset to the astng node
-rw-r--r--ChangeLog3
-rw-r--r--bases.py1
-rw-r--r--rebuilder.py4
3 files changed, 8 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index bf2bb361..7cb71b83 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,9 @@
Change log for the astng package
================================
+--
+ * added column offset information on nodes (patch by fawce)
+
2011-01-11 -- 0.21.1
* python3: handle file encoding; fix a lot of tests
diff --git a/bases.py b/bases.py
index 44dfd568..499dd6b6 100644
--- a/bases.py
+++ b/bases.py
@@ -336,6 +336,7 @@ class NodeNG(object):
lineno = None
fromlineno = None
tolineno = None
+ col_offset = None
# parent node in the tree
parent = None
# attributes containing child node(s) redefined in most concrete classes:
diff --git a/rebuilder.py b/rebuilder.py
index d86013e3..69173f2a 100644
--- a/rebuilder.py
+++ b/rebuilder.py
@@ -117,11 +117,15 @@ def _lineno_parent(oldnode, newnode, parent):
newnode.parent = parent
if hasattr(oldnode, 'lineno'):
newnode.lineno = oldnode.lineno
+ if hasattr(oldnode, 'col_offset'):
+ newnode.col_offset = oldnode.col_offset
def _set_infos(oldnode, newnode, parent):
newnode.parent = parent
if hasattr(oldnode, 'lineno'):
newnode.lineno = oldnode.lineno
+ if hasattr(oldnode, 'col_offset'):
+ newnode.col_offset = oldnode.col_offset
newnode.set_line_info(newnode.last_child()) # set_line_info accepts None