diff options
| author | 2018-12-19 17:10:22 +0100 | |
|---|---|---|
| committer | 2019-01-22 11:36:36 +0100 | |
| commit | 5ed42b6a2e99ae75177cb5790c908b12c4bc47b9 (patch) | |
| tree | 413a099a647477ff3805b51a05cc7663482c95c6 /tools/apilint/apilint.py | |
| parent | 6eb57b0f4a51255c656c71337fe41b81ff96a3dd (diff) | |
apilint: Fix API lint issues
Fixes a bug where only the name instead of the fully qualified name was
considered when looking for a class, which lead to faulty results for inner
classes.
Test: python tools/apilint/apilint_test.py
Change-Id: Ib015669ed3faef21d2bdd16f1e27bc55c8669d70
(cherry picked from commit 2c5cacfd36128f43f5fab4f0665acf69ac049a44)
Diffstat (limited to 'tools/apilint/apilint.py')
| -rw-r--r-- | tools/apilint/apilint.py | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/tools/apilint/apilint.py b/tools/apilint/apilint.py index b5a990e6e3cf..1eec218c7be3 100644 --- a/tools/apilint/apilint.py +++ b/tools/apilint/apilint.py @@ -267,6 +267,18 @@ def _parse_stream_to_generator(f): raise TypeError("send() must be followed by next(), not send()") +def _retry_iterator(it): + """Wraps an iterator, such that calling send(True) on it will redeliver the same element""" + for e in it: + while True: + retry = yield e + if not retry: + break + # send() was called, asking us to redeliver clazz on next(). Still need to yield + # a dummy value to the send() first though. + if (yield "Returning clazz on next()"): + raise TypeError("send() must be followed by next(), not send()") + def _parse_to_matching_class(classes, needle): """Takes a classes generator and parses it until it returns the class we're looking for @@ -276,8 +288,8 @@ def _parse_to_matching_class(classes, needle): if clazz.pkg.name < needle.pkg.name: # We haven't reached the right package yet continue - if clazz.name < needle.name: - # We haven't reached the right class yet + if clazz.pkg.name == needle.pkg.name and clazz.fullname < needle.fullname: + # We're in the right package, but not the right class yet continue if clazz.fullname == needle.fullname: return clazz |