Reduce duplication in visibility property management
Adds a couple of new methods to manage visibility property instances to
reduce duplication and encapsulate the implementation slightly better.
The AddVisibilityProperty method is exported as it will be needed by
other packages in follow up commits.
Bug: 155295806
Test: m nothing
Merged-In: Ic1a9bb1e151fc6ae65761344fd210b4e4ba74fbc
Change-Id: Ic1a9bb1e151fc6ae65761344fd210b4e4ba74fbc
(cherry picked from commit 5ec73ecc08342f0d16f2fb6f128df04d6553b83d)
diff --git a/android/defaults.go b/android/defaults.go
index fd707a4..6a908ea 100644
--- a/android/defaults.go
+++ b/android/defaults.go
@@ -176,18 +176,18 @@
defaultsVisibility := module.defaultsVisibility()
module.AddProperties(&base.nameProperties, defaultsVisibility)
- // The defaults_visibility property controls the visibility of a defaults module.
- base.primaryVisibilityProperty =
- newVisibilityProperty("defaults_visibility", &defaultsVisibility.Defaults_visibility)
-
// Unlike non-defaults modules the visibility property is not stored in m.base().commonProperties.
- // Instead it is stored in a separate instance of commonProperties created above so use that.
+ // Instead it is stored in a separate instance of commonProperties created above so clear the
+ // existing list of properties.
+ clearVisibilityProperties(module)
+
+ // The defaults_visibility property controls the visibility of a defaults module so it must be
+ // set as the primary property, which also adds it to the list.
+ setPrimaryVisibilityProperty(module, "defaults_visibility", &defaultsVisibility.Defaults_visibility)
+
// The visibility property needs to be checked (but not parsed) by the visibility module during
- // its checking phase and parsing phase.
- base.visibilityPropertyInfo = []visibilityProperty{
- base.primaryVisibilityProperty,
- newVisibilityProperty("visibility", &commonProperties.Visibility),
- }
+ // its checking phase and parsing phase so add it to the list as a normal property.
+ AddVisibilityProperty(module, "visibility", &commonProperties.Visibility)
base.module = module
}