summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohan Dahlin <johan@gnome.org>2010-09-20 23:15:51 -0300
committerJohan Dahlin <johan@gnome.org>2010-09-20 23:31:17 -0300
commit97db362fd8e294a2079cf07fdc12e4771ef17424 (patch)
tree5edfe4e5d10db010c6801f9ee14d8b7508cff497
parentf3bf705c1461d9bc64ced0e373b49bdf94319ec6 (diff)
downloadgobject-introspection-97db362fd8e294a2079cf07fdc12e4771ef17424.tar.gz
[IntrospectablePass] Improve error message
Send in block postions so we can get accurate line numbers for warnings emitted from this class.
-rw-r--r--giscanner/introspectablepass.py8
-rw-r--r--tests/warn/callback-invalid-scope.h2
-rw-r--r--tests/warn/return-gobject.h8
3 files changed, 15 insertions, 3 deletions
diff --git a/giscanner/introspectablepass.py b/giscanner/introspectablepass.py
index 0de25c8d..cc3a59d3 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 f6cfd87b..46292aa8 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 163d50cf..5e621c3a 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