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 5ec73ecc08
)
This commit is contained in:
@@ -480,3 +480,28 @@ func EffectiveVisibilityRules(ctx BaseModuleContext, module Module) []string {
|
||||
|
||||
return rule.Strings()
|
||||
}
|
||||
|
||||
// Clear the default visibility properties so they can be replaced.
|
||||
func clearVisibilityProperties(module Module) {
|
||||
module.base().visibilityPropertyInfo = nil
|
||||
}
|
||||
|
||||
// Add a property that contains visibility rules so that they are checked for
|
||||
// correctness.
|
||||
func AddVisibilityProperty(module Module, name string, stringsProperty *[]string) {
|
||||
addVisibilityProperty(module, name, stringsProperty)
|
||||
}
|
||||
|
||||
func addVisibilityProperty(module Module, name string, stringsProperty *[]string) visibilityProperty {
|
||||
base := module.base()
|
||||
property := newVisibilityProperty(name, stringsProperty)
|
||||
base.visibilityPropertyInfo = append(base.visibilityPropertyInfo, property)
|
||||
return property
|
||||
}
|
||||
|
||||
// Set the primary visibility property.
|
||||
//
|
||||
// Also adds the property to the list of properties to be validated.
|
||||
func setPrimaryVisibilityProperty(module Module, name string, stringsProperty *[]string) {
|
||||
module.base().primaryVisibilityProperty = addVisibilityProperty(module, name, stringsProperty)
|
||||
}
|
||||
|
Reference in New Issue
Block a user