[gobject-introspection] [IntrospectablePass] Improve error message



commit 97db362fd8e294a2079cf07fdc12e4771ef17424
Author: Johan Dahlin <johan gnome org>
Date:   Mon Sep 20 23:15:51 2010 -0300

    [IntrospectablePass] Improve error message
    
    Send in block postions so we can get accurate line numbers
    for warnings emitted from this class.

 giscanner/introspectablepass.py     |    8 ++++++--
 tests/warn/callback-invalid-scope.h |    2 +-
 tests/warn/return-gobject.h         |    8 ++++++++
 3 files changed, 15 insertions(+), 3 deletions(-)
---
diff --git a/giscanner/introspectablepass.py b/giscanner/introspectablepass.py
index 0de25c8..cc3a59d 100644
--- a/giscanner/introspectablepass.py
+++ b/giscanner/introspectablepass.py
@@ -44,16 +44,20 @@ class IntrospectablePass(object):
 """Virtual function %r has no known invoker""" % (vfunc.name, ),
                     context=node)
 
-    def _parameter_warning(self, parent, param, text, *args):
+    def _parameter_warning(self, parent, param, text, position=None):
         if hasattr(parent, 'symbol'):
             prefix = '%s: ' % (parent.symbol, )
+            block = self._blocks.get(parent.symbol)
+            if block:
+                position = block.position
         else:
             prefix = ''
         if isinstance(param, ast.Parameter):
             context = "argument %s: " % (param.argname, )
         else:
             context = "return value: "
-        message.warn_node(parent, prefix + context + text, *args)
+        message.warn_node(parent, prefix + context + text,
+                          positions=position)
 
     def _introspectable_param_analysis(self, parent, node):
         is_return = isinstance(node, ast.Return)
diff --git a/tests/warn/callback-invalid-scope.h b/tests/warn/callback-invalid-scope.h
index f6cfd87..46292aa 100644
--- a/tests/warn/callback-invalid-scope.h
+++ b/tests/warn/callback-invalid-scope.h
@@ -8,4 +8,4 @@
 void test_callback_invalid(GCallback *callback, gpointer user_data);
 
 // EXPECT:5: Warning: Test: Invalid scope 'invalid' for parameter 'callback'
-// EXPECT:8: Warning: Test: test_callback_invalid: argument callback: Missing (scope) annotation for callback without GDestroyNotify (valid: call, async)
+// EXPECT:3: Warning: Test: test_callback_invalid: argument callback: Missing (scope) annotation for callback without GDestroyNotify (valid: call, async)
diff --git a/tests/warn/return-gobject.h b/tests/warn/return-gobject.h
index 163d50c..5e621c3 100644
--- a/tests/warn/return-gobject.h
+++ b/tests/warn/return-gobject.h
@@ -3,3 +3,11 @@
 GObject * test_get_object(void);
 
 // EXPECT:3: Warning: Test: test_get_object: return value: Missing (transfer) annotation
+
+/**
+ * test_get_object2:
+ *
+ */
+GObject * test_get_object2(void);
+
+// EXPECT:7: Warning: Test: test_get_object2: return value: Missing (transfer) annotation



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]