From 63111882e794f786ab857c92b01383a457e843a4 Mon Sep 17 00:00:00 2001 From: michajlo Date: Thu, 30 Mar 2017 20:01:17 +0000 Subject: Delete STRING_DICT_UNARY This isn't used anymore, it's the same as STRING_DICT, deleting so no one tries to use it. PiperOrigin-RevId: 151738915 --- .../build/lib/packages/AttributeFormatter.java | 23 ---------- .../devtools/build/lib/packages/ProtoUtils.java | 2 - .../lib/query2/output/ProtoOutputFormatter.java | 1 - .../com/google/devtools/build/lib/syntax/Type.java | 6 --- src/main/protobuf/build.proto | 2 +- .../google/devtools/build/lib/syntax/TypeTest.java | 51 ---------------------- 6 files changed, 1 insertion(+), 84 deletions(-) diff --git a/src/main/java/com/google/devtools/build/lib/packages/AttributeFormatter.java b/src/main/java/com/google/devtools/build/lib/packages/AttributeFormatter.java index 4a1c283a3a..f14ca5db7d 100644 --- a/src/main/java/com/google/devtools/build/lib/packages/AttributeFormatter.java +++ b/src/main/java/com/google/devtools/build/lib/packages/AttributeFormatter.java @@ -30,7 +30,6 @@ import static com.google.devtools.build.lib.syntax.Type.INTEGER; import static com.google.devtools.build.lib.syntax.Type.INTEGER_LIST; import static com.google.devtools.build.lib.syntax.Type.STRING; import static com.google.devtools.build.lib.syntax.Type.STRING_DICT; -import static com.google.devtools.build.lib.syntax.Type.STRING_DICT_UNARY; import static com.google.devtools.build.lib.syntax.Type.STRING_LIST; import static com.google.devtools.build.lib.syntax.Type.STRING_LIST_DICT; @@ -49,7 +48,6 @@ import com.google.devtools.build.lib.query2.proto.proto2api.Build.LabelDictUnary import com.google.devtools.build.lib.query2.proto.proto2api.Build.LabelKeyedStringDictEntry; import com.google.devtools.build.lib.query2.proto.proto2api.Build.LabelListDictEntry; import com.google.devtools.build.lib.query2.proto.proto2api.Build.StringDictEntry; -import com.google.devtools.build.lib.query2.proto.proto2api.Build.StringDictUnaryEntry; import com.google.devtools.build.lib.query2.proto.proto2api.Build.StringListDictEntry; import com.google.devtools.build.lib.syntax.Type; import java.util.Collection; @@ -212,15 +210,6 @@ public class AttributeFormatter { .setValue(keyValueList.getValue()); builder.addStringDictValue(entry); } - } else if (type == STRING_DICT_UNARY) { - Map dict = (Map) value; - for (Map.Entry dictEntry : dict.entrySet()) { - StringDictUnaryEntry.Builder entry = - StringDictUnaryEntry.newBuilder() - .setKey(dictEntry.getKey()) - .setValue(dictEntry.getValue()); - builder.addStringDictUnaryValue(entry); - } } else if (type == STRING_LIST_DICT) { Map> dict = (Map>) value; for (Map.Entry> dictEntry : dict.entrySet()) { @@ -327,8 +316,6 @@ public class AttributeFormatter { void addIntListValue(int i); - void addStringDictUnaryValue(StringDictUnaryEntry.Builder builder); - void addStringDictValue(StringDictEntry.Builder builder); void addStringListDictValue(StringListDictEntry.Builder builder); @@ -397,11 +384,6 @@ public class AttributeFormatter { attributeBuilder.addIntListValue(i); } - @Override - public void addStringDictUnaryValue(StringDictUnaryEntry.Builder builder) { - attributeBuilder.addStringDictUnaryValue(builder); - } - @Override public void addStringDictValue(StringDictEntry.Builder builder) { attributeBuilder.addStringDictValue(builder); @@ -528,11 +510,6 @@ public class AttributeFormatter { selectorEntryBuilder.addIntListValue(i); } - @Override - public void addStringDictUnaryValue(StringDictUnaryEntry.Builder builder) { - selectorEntryBuilder.addStringDictUnaryValue(builder); - } - @Override public void addStringDictValue(StringDictEntry.Builder builder) { selectorEntryBuilder.addStringDictValue(builder); diff --git a/src/main/java/com/google/devtools/build/lib/packages/ProtoUtils.java b/src/main/java/com/google/devtools/build/lib/packages/ProtoUtils.java index 7c0335d406..29d56c6983 100644 --- a/src/main/java/com/google/devtools/build/lib/packages/ProtoUtils.java +++ b/src/main/java/com/google/devtools/build/lib/packages/ProtoUtils.java @@ -31,7 +31,6 @@ import static com.google.devtools.build.lib.syntax.Type.INTEGER; import static com.google.devtools.build.lib.syntax.Type.INTEGER_LIST; import static com.google.devtools.build.lib.syntax.Type.STRING; import static com.google.devtools.build.lib.syntax.Type.STRING_DICT; -import static com.google.devtools.build.lib.syntax.Type.STRING_DICT_UNARY; import static com.google.devtools.build.lib.syntax.Type.STRING_LIST; import static com.google.devtools.build.lib.syntax.Type.STRING_LIST_DICT; @@ -68,7 +67,6 @@ public class ProtoUtils { .put(BOOLEAN, Discriminator.BOOLEAN) .put(TRISTATE, Discriminator.TRISTATE) .put(INTEGER_LIST, Discriminator.INTEGER_LIST) - .put(STRING_DICT_UNARY, Discriminator.STRING_DICT_UNARY) .put(LABEL_KEYED_STRING_DICT, Discriminator.LABEL_KEYED_STRING_DICT) .build(); diff --git a/src/main/java/com/google/devtools/build/lib/query2/output/ProtoOutputFormatter.java b/src/main/java/com/google/devtools/build/lib/query2/output/ProtoOutputFormatter.java index f966afb88d..66fd324743 100644 --- a/src/main/java/com/google/devtools/build/lib/query2/output/ProtoOutputFormatter.java +++ b/src/main/java/com/google/devtools/build/lib/query2/output/ProtoOutputFormatter.java @@ -432,7 +432,6 @@ public class ProtoOutputFormatter extends AbstractUnorderedFormatter { // Same for maps as for collections. if (attrType == Type.STRING_DICT - || attrType == Type.STRING_DICT_UNARY || attrType == Type.STRING_LIST_DICT || attrType == BuildType.LABEL_DICT_UNARY || attrType == BuildType.LABEL_KEYED_STRING_DICT) { diff --git a/src/main/java/com/google/devtools/build/lib/syntax/Type.java b/src/main/java/com/google/devtools/build/lib/syntax/Type.java index fc89927c42..6a0a76b4bf 100644 --- a/src/main/java/com/google/devtools/build/lib/syntax/Type.java +++ b/src/main/java/com/google/devtools/build/lib/syntax/Type.java @@ -228,12 +228,6 @@ public abstract class Type { public static final DictType> STRING_LIST_DICT = DictType.create(STRING, STRING_LIST); - /** - * The type of a dictionary of {@linkplain #STRING strings}, where each entry - * maps to a single string value. - */ - public static final DictType STRING_DICT_UNARY = DictType.create(STRING, STRING); - /** * For ListType objects, returns the type of the elements of the list; for * all other types, returns null. (This non-obvious implementation strategy diff --git a/src/main/protobuf/build.proto b/src/main/protobuf/build.proto index fe4534abb8..029e0cfaf2 100644 --- a/src/main/protobuf/build.proto +++ b/src/main/protobuf/build.proto @@ -133,7 +133,7 @@ message Attribute { BOOLEAN = 14; // int, bool and string value TRISTATE = 15; // tristate, int and string value INTEGER_LIST = 16; // int_list_value - STRING_DICT_UNARY = 17; // string_dict_unary_value + STRING_DICT_UNARY = 17; // string_dict_unary_value (DEPRECATED) UNKNOWN = 18; // unknown type, use only for build extensions LABEL_DICT_UNARY = 19; // label_dict_unary_value SELECTOR_LIST = 20; // selector_list diff --git a/src/test/java/com/google/devtools/build/lib/syntax/TypeTest.java b/src/test/java/com/google/devtools/build/lib/syntax/TypeTest.java index 26d9a3955b..4efe9d0c9c 100644 --- a/src/test/java/com/google/devtools/build/lib/syntax/TypeTest.java +++ b/src/test/java/com/google/devtools/build/lib/syntax/TypeTest.java @@ -436,57 +436,6 @@ public class TypeTest { } } - @Test - public void testStringDictUnary() throws Exception { - Object input = ImmutableMap.of("foo", "bar", - "wiz", "bang"); - Map converted = - Type.STRING_DICT_UNARY.convert(input, null, currentRule); - Map expected = ImmutableMap.of( - "foo", "bar", - "wiz", "bang"); - assertEquals(expected, converted); - assertNotSame(expected, converted); - assertThat(collectLabels(Type.STRING_DICT_UNARY, converted)).isEmpty(); - } - - @Test - public void testStringDictUnaryBadFirstElement() throws Exception { - Object input = ImmutableMap.of(2, Arrays.asList("foo", "bar"), - "wiz", Arrays.asList("bang")); - try { - Type.STRING_DICT_UNARY.convert(input, null, currentRule); - fail(); - } catch (Type.ConversionException e) { - assertThat(e).hasMessage("expected value of type 'string' for dict key element, but got " - + "2 (int)"); - } - } - - @Test - public void testStringDictUnaryBadSecondElement() throws Exception { - Object input = ImmutableMap.of("foo", "bar", "wiz", MutableList.of(null, "bang")); - try { - Type.STRING_DICT_UNARY.convert(input, null, currentRule); - fail(); - } catch (Type.ConversionException e) { - assertThat(e).hasMessage("expected value of type 'string' for dict value element, but got " - + "[\"bang\"] (list)"); - } - } - - @Test - public void testStringDictUnaryBadElements1() throws Exception { - Object input = ImmutableMap.of("foo", "bar", Tuple.of("foo", "bar"), Tuple.of("wiz", "bang")); - try { - Type.STRING_DICT_UNARY.convert(input, null); - fail(); - } catch (Type.ConversionException e) { - assertThat(e).hasMessage("expected value of type 'string' for dict key element, but got " - + "(\"foo\", \"bar\") (tuple)"); - } - } - @Test public void testStringDictThrowsConversionException() throws Exception { try { -- cgit v1.2.3