[gobject-introspection] giscanner: give pointer to original comment block...
- From: Colin Walters <walters src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gobject-introspection] giscanner: give pointer to original comment block...
- Date: Wed, 9 Oct 2013 16:56:53 +0000 (UTC)
commit cc96177ec877153e7e5e55e6af270829da546015
Author: Dieter Verfaillie <dieterv optionexplicit be>
Date: Tue May 28 17:20:49 2013 +0200
giscanner: give pointer to original comment block...
...when complaining about multiple comment blocks
documenting the same identifier.
giscanner/annotationparser.py | 18 ++++++++++--------
giscanner/message.py | 11 +++++++----
tests/warn/annotationparser.h | 19 ++++++++++++++-----
3 files changed, 31 insertions(+), 17 deletions(-)
---
diff --git a/giscanner/annotationparser.py b/giscanner/annotationparser.py
index f5205a5..d5da84c 100644
--- a/giscanner/annotationparser.py
+++ b/giscanner/annotationparser.py
@@ -105,6 +105,7 @@ Refer to the `GTK-Doc manual`_ for more detailed usage information.
'''
+import os
import re
from . import message
@@ -856,15 +857,16 @@ class GtkDocCommentBlockParser(object):
continue
if comment_block is not None:
- # Note: previous versions of this parser did not check
- # if an identifier was already stored in comment_blocks,
- # so when multiple comment blocks where encountered documenting
- # the same identifier the last one seen "wins".
- # Keep this behavior for backwards compatibility, but
- # emit a warning.
+ # Note: previous versions of this parser did not check if an identifier was
+ # already stored in comment_blocks, so when different comment blocks where
+ # encountered documenting the same identifier the last comment block seen
+ # "wins". Keep this behavior for backwards compatibility, but emit a warning.
if comment_block.name in comment_blocks:
- message.warn("multiple comment blocks documenting '%s:' identifier." %
- (comment_block.name, ),
+ firstseen = comment_blocks[comment_block.name]
+ path = os.path.dirname(firstseen.position.filename)
+ message.warn('multiple comment blocks documenting \'%s:\' identifier '
+ '(already seen at %s).' %
+ (comment_block.name, firstseen.position.format(path)),
comment_block.position)
comment_blocks[comment_block.name] = comment_block
diff --git a/giscanner/message.py b/giscanner/message.py
index fc6100e..eca425a 100644
--- a/giscanner/message.py
+++ b/giscanner/message.py
@@ -53,9 +53,12 @@ class Position(object):
self.column or -1)
def format(self, cwd):
- filename = self.filename
- if filename.startswith(cwd):
- filename = filename[len(cwd):]
+ filename = os.path.realpath(self.filename)
+ cwd = os.path.realpath(cwd)
+ common_prefix = os.path.commonprefix((filename, cwd))
+ if common_prefix:
+ filename = os.path.relpath(filename, common_prefix)
+
if self.column is not None:
return '%s:%d:%d' % (filename, self.line, self.column)
elif self.line is not None:
@@ -73,7 +76,7 @@ class MessageLogger(object):
def __init__(self, namespace, output=None):
if output is None:
output = sys.stderr
- self._cwd = os.getcwd() + os.sep
+ self._cwd = os.getcwd()
self._output = output
self._namespace = namespace
self._enable_warnings = False
diff --git a/tests/warn/annotationparser.h b/tests/warn/annotationparser.h
index 87b632f..db04b5a 100644
--- a/tests/warn/annotationparser.h
+++ b/tests/warn/annotationparser.h
@@ -1,18 +1,27 @@
#include "common.h"
/**
- * test_symbol_twice_documented:
+ * test_symbol_thrice_documented:
*
* Documenting the same thing multiple times can lead to subtle bugs.
* For example, one comment block might have correct annotations...
**/
-void test_symbol_twice_documented();
+void test_symbol_thrice_documented();
/**
- * test_symbol_twice_documented:
+ * test_symbol_thrice_documented:
*
* ...and a different comment block (out of sync with the above) might have
- * no annotations at all. The last comment block seen by the parser "wins".
+ * no annotations at all. The last comment block seen by the parser "wins"...
**/
-// EXPECT:12: Warning: Test: multiple comment blocks documenting 'test_symbol_twice_documented:' identifier.
+// EXPECT:12: Warning: Test: multiple comment blocks documenting 'test_symbol_thrice_documented:' identifier
(already seen at annotationparser.h:4).
+
+
+/**
+ * test_symbol_thrice_documented:
+ *
+ * ...and yet another one.
+ **/
+
+// EXPECT:22: Warning: Test: multiple comment blocks documenting 'test_symbol_thrice_documented:' identifier
(already seen at annotationparser.h:12).
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]