diff options
author | Sundong Ahn <sundongahn@google.com> | 2020-03-30 09:35:49 +0900 |
---|---|---|
committer | Sundong Ahn <sundongahn@google.com> | 2020-03-30 09:50:45 +0900 |
commit | c9e30c0f72acab790f8f494a37b4316cfcf3f078 (patch) | |
tree | 78d04f8a5ef6a414b67dba731e2f4a6af9d0b4f0 | |
parent | 30b1c4f8d95ff5134517ed67d31989b1fa8ce273 (diff) | |
download | xsdc-c9e30c0f72acab790f8f494a37b4316cfcf3f078.tar.gz |
Support final and nullabilityandroid-mainline-11.0.0_r44android-mainline-11.0.0_r43android-mainline-11.0.0_r42android-mainline-11.0.0_r41android-mainline-11.0.0_r40android-mainline-11.0.0_r39android-mainline-11.0.0_r38android-mainline-11.0.0_r37android-mainline-11.0.0_r36android-mainline-11.0.0_r35android-mainline-11.0.0_r34android-mainline-11.0.0_r32android-mainline-11.0.0_r31android-mainline-11.0.0_r30android-mainline-11.0.0_r28android-mainline-11.0.0_r27android-mainline-11.0.0_r26android-mainline-11.0.0_r25android-mainline-11.0.0_r24android-mainline-11.0.0_r23android-mainline-11.0.0_r22android-mainline-11.0.0_r21android-mainline-11.0.0_r20android-mainline-11.0.0_r18android-mainline-11.0.0_r17android-mainline-11.0.0_r16android-mainline-11.0.0_r15android-mainline-11.0.0_r14android-mainline-11.0.0_r13android-mainline-11.0.0_r12android11-mainline-tethering-releaseandroid11-mainline-permission-releaseandroid11-mainline-os-statsd-releaseandroid11-mainline-networkstack-releaseandroid11-mainline-media-swcodec-releaseandroid11-mainline-media-releaseandroid11-mainline-extservices-releaseandroid11-mainline-documentsui-releaseandroid11-mainline-conscrypt-releaseandroid11-mainline-cellbroadcast-releaseandroid11-mainline-captiveportallogin-releaseandroid11-dev
If both final annotation and nullability annotation are present, the
final annotation can be ignored. So modify xsd parser code to not
ignore final annotation.
Bug: 151155782
Test: make update-api && make checkapi
Merged-In: Ib1e558cb77f912fbbf96dc1970ae02060bbf823d
Change-Id: Ib1e558cb77f912fbbf96dc1970ae02060bbf823d
(cherry picked from commit 8f946dced8299a7ff6a91b61b28c303db4901b0e)
-rw-r--r-- | src/com/android/xsdc/XsdHandler.java | 18 | ||||
-rw-r--r-- | tests/resources/simple_complex_content/api/current.txt | 8 | ||||
-rw-r--r-- | tests/resources/simple_complex_content/simple_complex_content.xsd | 2 |
3 files changed, 16 insertions, 12 deletions
diff --git a/src/com/android/xsdc/XsdHandler.java b/src/com/android/xsdc/XsdHandler.java index 5a7c0d4..a2cc57c 100644 --- a/src/com/android/xsdc/XsdHandler.java +++ b/src/com/android/xsdc/XsdHandler.java @@ -204,8 +204,10 @@ public class XsdHandler extends DefaultHandler { // Tags under simpleType <restriction>. They are ignored. break; case "annotation": - stateStack.peek().deprecated = isDeprecated(state.attributeMap, state.tags); - stateStack.peek().finalValue = isFinalValue(state.attributeMap, state.tags); + stateStack.peek().deprecated = isDeprecated(state.attributeMap, state.tags, + stateStack.peek().deprecated); + stateStack.peek().finalValue = isFinalValue(state.attributeMap, state.tags, + stateStack.peek().finalValue); stateStack.peek().nullability = getNullability(state.attributeMap, state.tags, stateStack.peek().nullability); break; @@ -656,22 +658,22 @@ public class XsdHandler extends DefaultHandler { state.finalValue, state.nullability); } - private boolean isDeprecated(Map<String, String> attributeMap,List<XsdTag> tags) - throws XsdParserException { + private boolean isDeprecated(Map<String, String> attributeMap,List<XsdTag> tags, + boolean deprecated) throws XsdParserException { String name = attributeMap.get("name"); if ("Deprecated".equals(name)) { return true; } - return false; + return deprecated; } - private boolean isFinalValue(Map<String, String> attributeMap,List<XsdTag> tags) - throws XsdParserException { + private boolean isFinalValue(Map<String, String> attributeMap,List<XsdTag> tags, + boolean finalValue) throws XsdParserException { String name = attributeMap.get("name"); if ("final".equals(name)) { return true; } - return false; + return finalValue; } private Nullability getNullability(Map<String, String> attributeMap,List<XsdTag> tags, diff --git a/tests/resources/simple_complex_content/api/current.txt b/tests/resources/simple_complex_content/api/current.txt index 601a57e..8ca1793 100644 --- a/tests/resources/simple_complex_content/api/current.txt +++ b/tests/resources/simple_complex_content/api/current.txt @@ -41,10 +41,10 @@ package simple.complex.content { public class SubAddress { ctor public SubAddress(); - method @Nullable public String getChoice1_optional(); - method @NonNull public String getChoice2_optional(); - method public void setChoice1_optional(@Nullable String); - method public void setChoice2_optional(@NonNull String); + method @Nullable public final String getChoice1_optional(); + method @NonNull public final String getChoice2_optional(); + method public final void setChoice1_optional(@Nullable String); + method public final void setChoice2_optional(@NonNull String); } public final class USAddressP extends simple.complex.content.Address { diff --git a/tests/resources/simple_complex_content/simple_complex_content.xsd b/tests/resources/simple_complex_content/simple_complex_content.xsd index dc66cd3..62a6497 100644 --- a/tests/resources/simple_complex_content/simple_complex_content.xsd +++ b/tests/resources/simple_complex_content/simple_complex_content.xsd @@ -34,10 +34,12 @@ <xs:complexType name="subAddress"> <xs:choice> <xs:element name="choice1" type="xs:string"> + <xs:annotation name="final"/> <xs:annotation name="nullable"/> </xs:element> <xs:element name="choice2" type="xs:string"> <xs:annotation name="nonnull"/> + <xs:annotation name="final"/> </xs:element> </xs:choice> </xs:complexType> |