...
1
16
17
18
19 package edit
20
21 import (
22 buildpb "github.com/bazelbuild/buildtools/build_proto"
23 "github.com/bazelbuild/buildtools/lang"
24 "github.com/bazelbuild/buildtools/tables"
25 )
26
27 var typeOf = lang.TypeOf
28
29
30 func IsList(attr string) bool {
31 overrideValue, isOverridden := tables.IsListArg[attr]
32 if isOverridden {
33 return overrideValue
34 }
35
36 isSortableList := tables.IsSortableListArg[attr]
37 if isSortableList {
38 return true
39 }
40 ty := typeOf[attr]
41 return ty == buildpb.Attribute_STRING_LIST ||
42 ty == buildpb.Attribute_LABEL_LIST ||
43 ty == buildpb.Attribute_OUTPUT_LIST ||
44 ty == buildpb.Attribute_FILESET_ENTRY_LIST ||
45 ty == buildpb.Attribute_INTEGER_LIST ||
46 ty == buildpb.Attribute_LICENSE ||
47 ty == buildpb.Attribute_DISTRIBUTION_SET
48 }
49
50
51 func IsIntList(attr string) bool {
52 return typeOf[attr] == buildpb.Attribute_INTEGER_LIST
53 }
54
55
56 func IsString(attr string) bool {
57 ty := typeOf[attr]
58 return ty == buildpb.Attribute_LABEL ||
59 ty == buildpb.Attribute_STRING ||
60 ty == buildpb.Attribute_OUTPUT
61 }
62
63
64 func IsStringDict(attr string) bool {
65 return typeOf[attr] == buildpb.Attribute_STRING_DICT
66 }
67
68
69 func ContainsLabels(kind, attr string) bool {
70 if kind == "package_group" && attr == "packages" {
71
72 return false
73 }
74 ty := typeOf[attr]
75 return ty == buildpb.Attribute_LABEL_LIST ||
76 ty == buildpb.Attribute_LABEL
77 }
78
View as plain text