Browse Source

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>
coverity
Markus Armbruster 3 years ago
parent
commit
15333abed9
  1. 4
      scripts/qapi/parser.py
  2. 2
      tests/qapi-schema/doc-bad-alternate-member.err
  3. 2
      tests/qapi-schema/doc-bad-boxed-command-arg.err
  4. 2
      tests/qapi-schema/doc-bad-command-arg.err
  5. 2
      tests/qapi-schema/doc-bad-enum-member.err
  6. 2
      tests/qapi-schema/doc-bad-event-arg.err
  7. 2
      tests/qapi-schema/doc-bad-feature.err
  8. 2
      tests/qapi-schema/doc-bad-union-member.err

4
scripts/qapi/parser.py

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

2
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

2
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

2
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

2
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

2
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

2
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

2
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

Loading…
Cancel
Save