Add generalized identifier resolution for AndroidManifest

Since more than one attribute can hold an identifier, refactor
identifier resolution into a separate method.
This commit is contained in:
Ed Minnix
2022-09-23 21:16:11 -04:00
parent cf3e5a0abe
commit 4c270fca91

View File

@@ -261,19 +261,30 @@ class AndroidComponentXmlElement extends XmlElement {
)
}
/**
* Gets the value of an identifier attribute, and tries to resolve it into a fully qualified identifier.
*/
string getResolvedIdentifier(AndroidIdentifierXmlAttribute identifier) {
exists(string name | name = identifier.getValue() |
if name.matches(".%")
then
result =
this.getParent()
.(XmlElement)
.getParent()
.(AndroidManifestXmlElement)
.getPackageAttributeValue() + name
else result = name
)
}
/**
* Gets the resolved value of the `android:name` attribute of this component element.
*/
string getResolvedComponentName() {
if this.getComponentName().matches(".%")
then
result =
this.getParent()
.(XmlElement)
.getParent()
.(AndroidManifestXmlElement)
.getPackageAttributeValue() + this.getComponentName()
else result = this.getComponentName()
exists(AndroidXmlAttribute attr | attr = this.getAnAttribute() and attr.getName() = "name" |
result = getResolvedIdentifier(attr)
)
}
/**