diff options
author | 2019-03-06 13:38:10 +0100 | |
---|---|---|
committer | 2019-03-06 13:40:03 +0100 | |
commit | 3478239c56d24d206ff7a5e5bbb0add4df5fadf2 (patch) | |
tree | 03c8bd8dca9cc2a9a4069e9675be5dc75aa6e801 | |
parent | 26968d81f8291f1dd4a0f8a7e962c60d62b9ef61 (diff) |
apilint: Lint unhidden @IntDef and @LongDef
@IntDefs and @LongDefs cannot be stored in a .class file, because the constant
names are lost. Instead, they are packaged out-of-band.
Therefore, they should never be in the API.
Test: python tools/apilint/apilint.py api/current.txt
Change-Id: If22e0cf7db0bb90dae6174bf546f2ec8be4e5458
-rw-r--r-- | tools/apilint/apilint.py | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/tools/apilint/apilint.py b/tools/apilint/apilint.py index a91fbe76be8d..f967c2fa6bcb 100644 --- a/tools/apilint/apilint.py +++ b/tools/apilint/apilint.py @@ -170,6 +170,7 @@ class Class(): self.ctors = [] self.fields = [] self.methods = [] + self.annotations = [] if sig_format == 2: V2LineParser(raw).parse_into_class(self) @@ -353,8 +354,8 @@ class V2LineParser(object): def parse_into_class(self, clazz): clazz.split = [] - annotations = self.parse_annotations() - if "@Deprecated" in annotations: + clazz.annotations = self.parse_annotations() + if "@Deprecated" in clazz.annotations: clazz.split.append("deprecated") clazz.split.extend(self.parse_modifiers()) kind = self.parse_one_of("class", "interface", "@interface", "enum") @@ -2000,6 +2001,16 @@ def has_nullability(annotations): @verifier +def verify_intdef(clazz): + """intdefs must be @hide, because the constant names cannot be stored in + the stubs (only the values are, which is not useful)""" + if "@interface" not in clazz.split: + return + if "@IntDef" in clazz.annotations or "@LongDef" in clazz.annotations: + error(clazz, None, None, "@IntDef and @LongDef annotations must be @hide") + + +@verifier def verify_singleton(clazz): """Catch singleton objects with constructors.""" |