aconfig: consolidate how fully qualified flag name is calculated
Add an extension trait to consolidate how the fully qualified package
name (<package>.<name>) is calculated and use this where possible.
This CL is a semantic change only. The intention of this CL is to reduce
the risk of future bugs.
Bug: N/A
Test: atest aconfig.test
Change-Id: Ibab6641dda3843337fbea02631c31a1fdd8fb4ab
diff --git a/tools/aconfig/src/protos.rs b/tools/aconfig/src/protos.rs
index 37eb67d..2684d20 100644
--- a/tools/aconfig/src/protos.rs
+++ b/tools/aconfig/src/protos.rs
@@ -308,7 +308,17 @@
}
fn create_sorting_key(pf: &ProtoParsedFlag) -> String {
- format!("{}.{}", pf.package(), pf.name())
+ pf.fully_qualified_name()
+ }
+}
+
+pub trait ParsedFlagExt {
+ fn fully_qualified_name(&self) -> String;
+}
+
+impl ParsedFlagExt for ProtoParsedFlag {
+ fn fully_qualified_name(&self) -> String {
+ format!("{}.{}", self.package(), self.name())
}
}