Java: Member.getQualifiedName() tweaked

It now includes the qualified name of the declaring type.
This commit is contained in:
Ian Lynagh
2022-09-13 16:05:51 +01:00
parent fc445736b2
commit 6a63b86f8a
3 changed files with 11 additions and 4 deletions

View File

@@ -0,0 +1,4 @@
---
category: minorAnalysis
---
* The `Member.getQualifiedName()` predicate result now includes the qualified name of the declaring type.

View File

@@ -20,8 +20,12 @@ class Member extends Element, Annotatable, Modifiable, @member {
/** Gets the type in which this member is declared. */
RefType getDeclaringType() { declaresMember(result, this) }
/** Gets the qualified name of this member. */
string getQualifiedName() { result = this.getDeclaringType().getName() + "." + this.getName() }
/**
* Gets the qualified name of this member.
* This is useful for debugging, but for normal use `hasQualifiedName`
* is recommended, as it is more efficient.
*/
string getQualifiedName() { result = this.getDeclaringType().getQualifiedName() + "." + this.getName() }
/**
* Holds if this member has the specified name and is declared in the

View File

@@ -93,8 +93,7 @@ class ExternalApiDataNode extends DataFlow::Node {
/** Gets the description of the method being called. */
string getMethodDescription() {
result =
this.getMethod().getDeclaringType().getPackage() + "." + this.getMethod().getQualifiedName()
result = this.getMethod().getQualifiedName()
}
}