diff options
author | Makoto Onuki <omakoto@google.com> | 2020-06-22 10:17:02 -0700 |
---|---|---|
committer | Makoto Onuki <omakoto@google.com> | 2020-06-23 09:35:36 -0700 |
commit | eab9e7f8014fa67164fb9a14ccd9dd624c802c51 (patch) | |
tree | c64628fbc16a9fa621395d2451e789c99dafbc5d /tools/aapt2/java/ClassDefinition.h | |
parent | bdc57bef813d07a837202bae3040c98dd64506a0 (diff) |
Don't add API annotations in the internal R.java
I'm trying to enable a check for the following structure:
```
/** @hide */
public class Class1 {
/** @hide */
@SystemApi // Invalid because the class is hidden.
public void method1() { }
}
```
The internal R.java file violates this, which this change is going to fix.
Bug: 159162473
Test: build (treehugger)
Test: atest aapt2_tests
Merged-in: I613e8611ddaf5f8e4761d351d4cd0142d59c7cc9
Change-Id: I613e8611ddaf5f8e4761d351d4cd0142d59c7cc9
Diffstat (limited to 'tools/aapt2/java/ClassDefinition.h')
-rw-r--r-- | tools/aapt2/java/ClassDefinition.h | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/tools/aapt2/java/ClassDefinition.h b/tools/aapt2/java/ClassDefinition.h index fb11266f1761..1e4b6816075a 100644 --- a/tools/aapt2/java/ClassDefinition.h +++ b/tools/aapt2/java/ClassDefinition.h @@ -50,7 +50,7 @@ class ClassMember { // Writes the class member to the Printer. Subclasses should derive this method // to write their own data. Call this base method from the subclass to write out // this member's comments/annotations. - virtual void Print(bool final, text::Printer* printer) const; + virtual void Print(bool final, text::Printer* printer, bool strip_api_annotations = false) const; private: AnnotationProcessor processor_; @@ -70,10 +70,11 @@ class PrimitiveMember : public ClassMember { return name_; } - void Print(bool final, text::Printer* printer) const override { + void Print(bool final, text::Printer* printer, bool strip_api_annotations = false) + const override { using std::to_string; - ClassMember::Print(final, printer); + ClassMember::Print(final, printer, strip_api_annotations); printer->Print("public static "); if (final) { @@ -104,8 +105,9 @@ class PrimitiveMember<std::string> : public ClassMember { return name_; } - void Print(bool final, text::Printer* printer) const override { - ClassMember::Print(final, printer); + void Print(bool final, text::Printer* printer, bool strip_api_annotations = false) + const override { + ClassMember::Print(final, printer, strip_api_annotations); printer->Print("public static "); if (final) { @@ -142,8 +144,9 @@ class PrimitiveArrayMember : public ClassMember { return name_; } - void Print(bool final, text::Printer* printer) const override { - ClassMember::Print(final, printer); + void Print(bool final, text::Printer* printer, bool strip_api_annotations = false) + const override { + ClassMember::Print(final, printer, strip_api_annotations); printer->Print("public static final int[] ").Print(name_).Print("={"); printer->Indent(); @@ -195,7 +198,7 @@ class MethodDefinition : public ClassMember { return false; } - void Print(bool final, text::Printer* printer) const override; + void Print(bool final, text::Printer* printer, bool strip_api_annotations = false) const override; private: DISALLOW_COPY_AND_ASSIGN(MethodDefinition); @@ -209,7 +212,7 @@ enum class ClassQualifier { kNone, kStatic }; class ClassDefinition : public ClassMember { public: static void WriteJavaFile(const ClassDefinition* def, const android::StringPiece& package, - bool final, io::OutputStream* out); + bool final, bool strip_api_annotations, io::OutputStream* out); ClassDefinition(const android::StringPiece& name, ClassQualifier qualifier, bool createIfEmpty) : name_(name.to_string()), qualifier_(qualifier), create_if_empty_(createIfEmpty) {} @@ -227,7 +230,7 @@ class ClassDefinition : public ClassMember { return name_; } - void Print(bool final, text::Printer* printer) const override; + void Print(bool final, text::Printer* printer, bool strip_api_annotations = false) const override; private: DISALLOW_COPY_AND_ASSIGN(ClassDefinition); |