Merge "bpfix: remove hidl_interface types"
diff --git a/bpfix/bpfix/bpfix.go b/bpfix/bpfix/bpfix.go
index 4633aa6..0516279 100644
--- a/bpfix/bpfix/bpfix.go
+++ b/bpfix/bpfix/bpfix.go
@@ -120,6 +120,10 @@
Name: "removeEmptyLibDependencies",
Fix: removeEmptyLibDependencies,
},
+ {
+ Name: "removeHidlInterfaceTypes",
+ Fix: removeHidlInterfaceTypes,
+ },
}
func NewFixRequest() FixRequest {
@@ -698,6 +702,18 @@
return nil
}
+// Removes hidl_interface 'types' which are no longer needed
+func removeHidlInterfaceTypes(f *Fixer) error {
+ for _, def := range f.tree.Defs {
+ mod, ok := def.(*parser.Module)
+ if !(ok && mod.Type == "hidl_interface") {
+ continue
+ }
+ removeProperty(mod, "types")
+ }
+ return nil
+}
+
// Converts the default source list property, 'srcs', to a single source property with a given name.
// "LOCAL_MODULE" reference is also resolved during the conversion process.
func convertToSingleSource(mod *parser.Module, srcPropertyName string) {
diff --git a/bpfix/bpfix/bpfix_test.go b/bpfix/bpfix/bpfix_test.go
index 032282f..38cefdd 100644
--- a/bpfix/bpfix/bpfix_test.go
+++ b/bpfix/bpfix/bpfix_test.go
@@ -887,3 +887,34 @@
})
}
}
+
+func TestRemoveHidlInterfaceTypes(t *testing.T) {
+ tests := []struct {
+ name string
+ in string
+ out string
+ }{
+ {
+ name: "remove types",
+ in: `
+ hidl_interface {
+ name: "foo@1.0",
+ types: ["ParcelFooBar"],
+ }
+ `,
+ out: `
+ hidl_interface {
+ name: "foo@1.0",
+
+ }
+ `,
+ },
+ }
+ for _, test := range tests {
+ t.Run(test.name, func(t *testing.T) {
+ runPass(t, test.in, test.out, func(fixer *Fixer) error {
+ return removeHidlInterfaceTypes(fixer)
+ })
+ })
+ }
+}