summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSylvain Th?nault <sylvain.thenault@logilab.fr>2011-06-16 19:20:23 +0200
committerSylvain Th?nault <sylvain.thenault@logilab.fr>2011-06-16 19:20:23 +0200
commit2ece50559bea3ea01aabea7fba3cc3173ff25270 (patch)
tree8e8b3e23eb92740581a3a6e6575417c777c46503
parent8de73909a123440e7ae42a27297e91ae11a6585f (diff)
downloadpylint-2ece50559bea3ea01aabea7fba3cc3173ff25270.tar.gz
closes #69220: add column offset to the astng node
-rw-r--r--ChangeLog3
-rw-r--r--reporters/html.py4
-rw-r--r--reporters/text.py6
-rw-r--r--utils.py7
4 files changed, 14 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index f7c85c6..a405fbb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,9 @@
ChangeLog for PyLint
====================
+ --
+ * #69220: add column offset to the reports
+
2011-01-11 -- 0.23.0
* documentation update, add manpages
diff --git a/reporters/html.py b/reporters/html.py
index 2c8832c..e1f9b1f 100644
--- a/reporters/html.py
+++ b/reporters/html.py
@@ -35,7 +35,7 @@ class HTMLReporter(BaseReporter):
def add_message(self, msg_id, location, msg):
"""manage message of different type and in the context of path"""
- module, obj, line = location[1:]
+ module, obj, line, col_offset = location[1:]
if self.include_ids:
sigle = msg_id
else:
@@ -59,7 +59,7 @@ class HTMLReporter(BaseReporter):
"""
if self.msgs:
# add stored messages to the layout
- msgs = ['type', 'module', 'object', 'line', 'message']
+ msgs = ['type', 'module', 'object', 'line', 'col_offset', 'message']
msgs += self.msgs
sect = Section('Messages')
layout.append(sect)
diff --git a/reporters/text.py b/reporters/text.py
index 2ceb6ba..a40fc2b 100644
--- a/reporters/text.py
+++ b/reporters/text.py
@@ -47,7 +47,7 @@ class TextReporter(BaseReporter):
def add_message(self, msg_id, location, msg):
"""manage message of different type and in the context of path"""
- module, obj, line = location[1:]
+ module, obj, line, col_offset = location[1:]
if module not in self._modules:
if module:
self.writeln('************* Module %s' % module)
@@ -60,7 +60,7 @@ class TextReporter(BaseReporter):
sigle = msg_id
else:
sigle = msg_id[0]
- self.writeln('%s:%3s%s: %s' % (sigle, line, obj, msg))
+ self.writeln('%s:%3s,%s%s: %s' % (sigle, line, col_offset, obj, msg))
def _display(self, layout):
"""launch layouts display"""
@@ -85,7 +85,7 @@ class ParseableTextReporter(TextReporter):
def add_message(self, msg_id, location, msg):
"""manage message of different type and in the context of path"""
- path, _, obj, line = location
+ path, _, obj, line, _ = location
if obj:
obj = ', %s' % obj
if self.include_ids:
diff --git a/utils.py b/utils.py
index 6037974..67c21c4 100644
--- a/utils.py
+++ b/utils.py
@@ -249,6 +249,11 @@ class MessagesHandlerMixIn:
"""
if line is None and node is not None:
line = node.fromlineno
+
+ col_offset = None
+ if hasattr(node, 'col_offset'):
+ col_offset = node.col_offset #measured in bytes for utf-8, divide by two for chars?
+
# should this message be displayed
if not self.is_message_enabled(msgid, line):
return
@@ -273,7 +278,7 @@ class MessagesHandlerMixIn:
module, obj = get_module_and_frameid(node)
path = node.root().file
# add the message
- self.reporter.add_message(msgid, (path, module, obj, line or 1), msg)
+ self.reporter.add_message(msgid, (path, module, obj, line or 1, col_offset or 0), msg)
def help_message(self, msgids):
"""display help messages for the given message identifiers"""