aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar apell <apell@google.com>2017-05-24 18:42:42 +0200
committerGravatar Irina Iancu <elenairina@google.com>2017-05-26 09:34:51 +0200
commitcf623c32ee369efbced6f1558eb07d5979213228 (patch)
treef0371c6dc0402daea71aa0ecfde4885e265c580e /src
parent4521882c2e67bcc76d1b191e73ae8058995e0ef5 (diff)
Fix bug with combining resource attributes. Attributes were reporting that they were over-writable in all cases instead of differentiating by attribute type.
RELNOTES: None. PiperOrigin-RevId: 156999284
Diffstat (limited to 'src')
-rw-r--r--src/tools/android/java/com/google/devtools/build/android/FullyQualifiedName.java12
-rw-r--r--src/tools/android/java/com/google/devtools/build/android/xml/ResourcesAttribute.java13
2 files changed, 18 insertions, 7 deletions
diff --git a/src/tools/android/java/com/google/devtools/build/android/FullyQualifiedName.java b/src/tools/android/java/com/google/devtools/build/android/FullyQualifiedName.java
index 836239d6be..938627afa5 100644
--- a/src/tools/android/java/com/google/devtools/build/android/FullyQualifiedName.java
+++ b/src/tools/android/java/com/google/devtools/build/android/FullyQualifiedName.java
@@ -25,6 +25,7 @@ import com.google.common.collect.ImmutableList.Builder;
import com.google.common.collect.Iterators;
import com.google.common.collect.PeekingIterator;
import com.google.devtools.build.android.proto.SerializeFormat;
+import com.google.devtools.build.android.xml.ResourcesAttribute;
import java.io.IOException;
import java.io.OutputStream;
import java.nio.file.Path;
@@ -63,7 +64,7 @@ public class FullyQualifiedName implements DataKey {
public String getName();
public ConcreteType getType();
- public boolean isOverwritable();
+ public boolean isOverwritable(FullyQualifiedName fqn);
public int compareTo(Type other);
@Override public boolean equals(Object obj);
@Override public int hashCode();
@@ -99,7 +100,7 @@ public class FullyQualifiedName implements DataKey {
}
@Override
- public boolean isOverwritable() {
+ public boolean isOverwritable(FullyQualifiedName fqn) {
return !(resourceType == ResourceType.ID
|| resourceType == ResourceType.PUBLIC
|| resourceType == ResourceType.STYLEABLE);
@@ -182,7 +183,10 @@ public class FullyQualifiedName implements DataKey {
}
@Override
- public boolean isOverwritable() {
+ public boolean isOverwritable(FullyQualifiedName fqn) {
+ if (this == RESOURCES_ATTRIBUTE) {
+ return !ResourcesAttribute.AttributeType.from(fqn.name()).isCombining();
+ }
return true;
}
@@ -531,7 +535,7 @@ public class FullyQualifiedName implements DataKey {
}
public boolean isOverwritable() {
- return type.isOverwritable();
+ return type.isOverwritable(this);
}
/** Creates a FullyQualifiedName from this one with a different package. */
diff --git a/src/tools/android/java/com/google/devtools/build/android/xml/ResourcesAttribute.java b/src/tools/android/java/com/google/devtools/build/android/xml/ResourcesAttribute.java
index 9202d599b5..a54667ecdb 100644
--- a/src/tools/android/java/com/google/devtools/build/android/xml/ResourcesAttribute.java
+++ b/src/tools/android/java/com/google/devtools/build/android/xml/ResourcesAttribute.java
@@ -48,7 +48,11 @@ public class ResourcesAttribute implements XmlResourceValue {
}
};
- private static enum AttributeType {
+ /**
+ * Represents the semantic meaning of an xml attribute and how it is combined with other
+ * attributes of the same type.
+ */
+ public static enum AttributeType {
UNCOMBINABLE(null, null),
TOOLS_IGNORE("{http://schemas.android.com/tools}ignore", COMMA_SEPARATED_COMBINER),
TOOLS_MENU("{http://schemas.android.com/tools}menu", COMMA_SEPARATED_COMBINER),
@@ -74,6 +78,10 @@ public class ResourcesAttribute implements XmlResourceValue {
this.name = name;
this.combiner = combiner;
}
+
+ public boolean isCombining() {
+ return this != UNCOMBINABLE;
+ }
}
public static ResourcesAttribute of(FullyQualifiedName fqn, String name, String value) {
@@ -94,7 +102,6 @@ public class ResourcesAttribute implements XmlResourceValue {
private final String value;
private ResourcesAttribute(AttributeType type, String name, String value) {
-
this.type = type;
this.name = name;
this.value = value;
@@ -148,7 +155,7 @@ public class ResourcesAttribute implements XmlResourceValue {
}
public boolean isCombining() {
- return type != AttributeType.UNCOMBINABLE;
+ return type.isCombining();
}
@Override