closes #69217: please add column offset to the astng node

authorSylvain Thénault <sylvain.thenault@logilab.fr>
changeset93ffcccc595f
branchdefault
phasepublic
hiddenno
parent revision#eca5337e3675 (merge py3k changes)
child revision#99f77cc74cd5 closes #70497: Crash on AttributeError: 'NoneType' object has no attribute '_infer_name' by fixing constant factory
files modified by this revision
ChangeLog
bases.py
rebuilder.py
# HG changeset patch
# User Sylvain Thénault <sylvain.thenault@logilab.fr>
# Date 1308244395 -7200
# Thu Jun 16 19:13:15 2011 +0200
# Node ID 93ffcccc595f44e4f465fc7dc944754bb4bbfa59
# Parent eca5337e3675329f7ee461fe0fea2576eb5ff070
closes #69217: please add column offset to the astng node

diff --git a/ChangeLog b/ChangeLog
@@ -1,8 +1,11 @@
1  Change log for the astng package
2  ================================
3 
4 +--
5 +    * added column offset information on nodes (patch by fawce)
6 +
7  2011-01-11  --  0.21.1
8      * python3: handle file encoding; fix a lot of tests
9 
10      * fix #52006: "True" and "False" can be assigned as variable in Python2x
11 
diff --git a/bases.py b/bases.py
@@ -334,10 +334,11 @@
12      is_function = False # True for Function nodes
13      # attributes below are set by the builder module or by raw factories
14      lineno = None
15      fromlineno = None
16      tolineno = None
17 +    col_offset = None
18      # parent node in the tree
19      parent = None
20      # attributes containing child node(s) redefined in most concrete classes:
21      _astng_fields = ()
22 
diff --git a/rebuilder.py b/rebuilder.py
@@ -115,15 +115,19 @@
23 
24  def _lineno_parent(oldnode, newnode, parent):
25      newnode.parent = parent
26      if hasattr(oldnode, 'lineno'):
27          newnode.lineno = oldnode.lineno
28 +    if hasattr(oldnode, 'col_offset'):
29 +        newnode.col_offset = oldnode.col_offset
30 
31  def _set_infos(oldnode, newnode, parent):
32      newnode.parent = parent
33      if hasattr(oldnode, 'lineno'):
34          newnode.lineno = oldnode.lineno
35 +    if hasattr(oldnode, 'col_offset'):
36 +        newnode.col_offset = oldnode.col_offset
37      newnode.set_line_info(newnode.last_child()) # set_line_info accepts None
38 
39 
40 
41