aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/tools/android/java/com/google/devtools/build/android/xml
diff options
context:
space:
mode:
authorGravatar corysmith <corysmith@google.com>2018-04-03 08:35:51 -0700
committerGravatar Copybara-Service <copybara-piper@google.com>2018-04-03 08:37:36 -0700
commit5437b080f3ba8b51e502027cb2df15ec80cd2fbf (patch)
treee31160a5783e484b3098a0682464ae79876d02b8 /src/tools/android/java/com/google/devtools/build/android/xml
parenta8023b796db7d05e329d0eb9a51cb4ce8222e4a0 (diff)
Automated rollback of commit e8bed799d59526541afa2a0e9ef5d4c49e3ba390.
*** Reason for rollback *** Rolling forward with improved handling and testing for Styleables, and correct package management. *** Original change description *** Automated rollback of commit a76f7db51a90cc2e35c1d66782056c310729eef0. *** Reason for rollback *** Breaks Kix. *** Original change description *** Modify the .flat decompilation to account for multiple configurations by converting the aapt2 proto ConfigValue to a FolderConfiguration. Adds new aapt2 compiled deserialization test. RELNOTES: None PiperOrigin-RevId: 191444658
Diffstat (limited to 'src/tools/android/java/com/google/devtools/build/android/xml')
-rw-r--r--src/tools/android/java/com/google/devtools/build/android/xml/StyleableXmlResourceValue.java29
1 files changed, 18 insertions, 11 deletions
diff --git a/src/tools/android/java/com/google/devtools/build/android/xml/StyleableXmlResourceValue.java b/src/tools/android/java/com/google/devtools/build/android/xml/StyleableXmlResourceValue.java
index c9661690cf..72707cf87d 100644
--- a/src/tools/android/java/com/google/devtools/build/android/xml/StyleableXmlResourceValue.java
+++ b/src/tools/android/java/com/google/devtools/build/android/xml/StyleableXmlResourceValue.java
@@ -18,6 +18,7 @@ import com.android.aapt.Resources.Value;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Function;
import com.google.common.base.MoreObjects;
+import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableMap.Builder;
import com.google.common.collect.Iterables;
@@ -165,16 +166,22 @@ public class StyleableXmlResourceValue implements XmlResourceValue {
}
public static XmlResourceValue from(
- Value proto, Map<String, Entry<FullyQualifiedName, Boolean>> fullyQualifiedNames) {
+ Value proto, Map<String, Boolean> qualifiedReferenceInlineStatus) {
Map<FullyQualifiedName, Boolean> attributes = new HashMap<>();
Styleable styleable = proto.getCompoundValue().getStyleable();
for (Styleable.Entry entry : styleable.getEntryList()) {
- String attrName = entry.getAttr().getName();
-
- Entry<FullyQualifiedName, Boolean> fqnEntry = fullyQualifiedNames.get(attrName);
- attributes.put(fqnEntry.getKey(), fqnEntry.getValue());
- fqnEntry.setValue(false);
+ final FullyQualifiedName reference =
+ FullyQualifiedName.fromReference(entry.getAttr().getName());
+ final String qualifiedReference = reference.asQualifiedReference();
+ Preconditions.checkArgument(
+ qualifiedReferenceInlineStatus.containsKey(qualifiedReference),
+ "Styleable reference %s is not in %s",
+ qualifiedReference,
+ qualifiedReferenceInlineStatus.keySet());
+
+ attributes.put(reference, qualifiedReferenceInlineStatus.get(qualifiedReference));
+ qualifiedReferenceInlineStatus.put(qualifiedReference, false);
}
return of(ImmutableMap.copyOf(attributes));
@@ -202,12 +209,12 @@ public class StyleableXmlResourceValue implements XmlResourceValue {
/**
* Combines this instance with another {@link StyleableXmlResourceValue}.
*
- * Defining two Styleables (undocumented in the official Android Docs) with the same
- * {@link FullyQualifiedName} results in a single Styleable containing a union of all the
- * attribute references.
+ * <p>Defining two Styleables (undocumented in the official Android Docs) with the same {@link
+ * FullyQualifiedName} results in a single Styleable containing a union of all the attribute
+ * references.
*
- * @param value Another {@link StyleableXmlResourceValue} with the same
- * {@link FullyQualifiedName}.
+ * @param value Another {@link StyleableXmlResourceValue} with the same {@link
+ * FullyQualifiedName}.
* @return {@link StyleableXmlResourceValue} containing a sorted union of the attribute
* references.
* @throws IllegalArgumentException if value is not an {@link StyleableXmlResourceValue}.