Переглянути джерело

qapi: Improve error position for bogus argument descriptions

When documented arguments don't exist, the error message points to the
beginning of the definition comment.  Point to the first bogus
argument description instead.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-ID: <20240216145841.2099240-6-armbru@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Markus Armbruster 1 рік тому
батько
коміт
15333abed9

+ 3 - 1
scripts/qapi/parser.py

@@ -472,6 +472,8 @@ class Section:
         # pylint: disable=too-few-public-methods
         # pylint: disable=too-few-public-methods
         def __init__(self, parser: QAPISchemaParser,
         def __init__(self, parser: QAPISchemaParser,
                      name: Optional[str] = None):
                      name: Optional[str] = None):
+            # section source info, i.e. where it begins
+            self.info = parser.info
             # parser, for error messages about indentation
             # parser, for error messages about indentation
             self._parser = parser
             self._parser = parser
             # optional section name (argument/member or section name)
             # optional section name (argument/member or section name)
@@ -770,7 +772,7 @@ def check_args_section(
                      if not section.member]
                      if not section.member]
             if bogus:
             if bogus:
                 raise QAPISemError(
                 raise QAPISemError(
-                    self.info,
+                    args[bogus[0]].info,
                     "documented %s%s '%s' %s not exist" % (
                     "documented %s%s '%s' %s not exist" % (
                         what,
                         what,
                         "s" if len(bogus) > 1 else "",
                         "s" if len(bogus) > 1 else "",

+ 1 - 1
tests/qapi-schema/doc-bad-alternate-member.err

@@ -1 +1 @@
-doc-bad-alternate-member.json:3: documented members 'aa', 'bb' do not exist
+doc-bad-alternate-member.json:7: documented members 'aa', 'bb' do not exist

+ 1 - 1
tests/qapi-schema/doc-bad-boxed-command-arg.err

@@ -1 +1 @@
-doc-bad-boxed-command-arg.json:9: documented member 'a' does not exist
+doc-bad-boxed-command-arg.json:11: documented member 'a' does not exist

+ 1 - 1
tests/qapi-schema/doc-bad-command-arg.err

@@ -1 +1 @@
-doc-bad-command-arg.json:3: documented member 'b' does not exist
+doc-bad-command-arg.json:6: documented member 'b' does not exist

+ 1 - 1
tests/qapi-schema/doc-bad-enum-member.err

@@ -1 +1 @@
-doc-bad-enum-member.json:3: documented member 'a' does not exist
+doc-bad-enum-member.json:5: documented member 'a' does not exist

+ 1 - 1
tests/qapi-schema/doc-bad-event-arg.err

@@ -1 +1 @@
-doc-bad-event-arg.json:3: documented member 'a' does not exist
+doc-bad-event-arg.json:5: documented member 'a' does not exist

+ 1 - 1
tests/qapi-schema/doc-bad-feature.err

@@ -1 +1 @@
-doc-bad-feature.json:3: documented feature 'a' does not exist
+doc-bad-feature.json:7: documented feature 'a' does not exist

+ 1 - 1
tests/qapi-schema/doc-bad-union-member.err

@@ -1 +1 @@
-doc-bad-union-member.json:3: documented members 'a', 'b' do not exist
+doc-bad-union-member.json:5: documented members 'a', 'b' do not exist