Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 748ed1ad authored by Adrian Roos's avatar Adrian Roos Committed by android-build-merger
Browse files

Merge "apilint: Lint unhidden @IntDef and @LongDef" am: 44359241

am: cec0f35f

Change-Id: Ie5646faa1b8bf2665d70ed683dbd365e6c550c13
parents 872fe405 cec0f35f
Loading
Loading
Loading
Loading
+13 −2
Original line number Original line Diff line number Diff line
@@ -170,6 +170,7 @@ class Class():
        self.ctors = []
        self.ctors = []
        self.fields = []
        self.fields = []
        self.methods = []
        self.methods = []
        self.annotations = []


        if sig_format == 2:
        if sig_format == 2:
            V2LineParser(raw).parse_into_class(self)
            V2LineParser(raw).parse_into_class(self)
@@ -353,8 +354,8 @@ class V2LineParser(object):


    def parse_into_class(self, clazz):
    def parse_into_class(self, clazz):
        clazz.split = []
        clazz.split = []
        annotations = self.parse_annotations()
        clazz.annotations = self.parse_annotations()
        if "@Deprecated" in annotations:
        if "@Deprecated" in clazz.annotations:
            clazz.split.append("deprecated")
            clazz.split.append("deprecated")
        clazz.split.extend(self.parse_modifiers())
        clazz.split.extend(self.parse_modifiers())
        kind = self.parse_one_of("class", "interface", "@interface", "enum")
        kind = self.parse_one_of("class", "interface", "@interface", "enum")
@@ -1999,6 +2000,16 @@ def has_nullability(annotations):
    return "@NonNull" in annotations or "@Nullable" in annotations
    return "@NonNull" in annotations or "@Nullable" in 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
@verifier
def verify_singleton(clazz):
def verify_singleton(clazz):
    """Catch singleton objects with constructors."""
    """Catch singleton objects with constructors."""