Merge pull request #15740 from smowton/smowton/feature/call-and-type-telemetry

Java: add extraction quality telemetry; improve stringification of some erroneous expressions
This commit is contained in:
Chris Smowton
2024-02-29 16:51:51 +00:00
committed by GitHub
18 changed files with 194 additions and 7 deletions

View File

@@ -2065,7 +2065,11 @@ class MethodCall extends Expr, Call, @methodaccess {
override Stmt getEnclosingStmt() { result = Expr.super.getEnclosingStmt() }
/** Gets a printable representation of this expression. */
override string toString() { result = this.printAccess() }
override string toString() {
if exists(this.getMethod())
then result = this.printAccess()
else result = "<Call to unknown method>"
}
/** Gets a printable representation of this expression. */
string printAccess() { result = this.getMethod().getName() + "(...)" }
@@ -2128,13 +2132,19 @@ class TypeAccess extends Expr, Annotatable, @typeaccess {
/** Gets the compilation unit in which this type access occurs. */
override CompilationUnit getCompilationUnit() { result = Expr.super.getCompilationUnit() }
/** Gets a printable representation of this expression. */
override string toString() {
private string toNormalString() {
result = this.getQualifier().toString() + "." + this.getType().toString()
or
not this.hasQualifier() and result = this.getType().toString()
}
/** Gets a printable representation of this expression. */
override string toString() {
if this.getType() instanceof ErrorType
then result = "<TypeAccess of ErrorType>"
else result = this.toNormalString()
}
override string getAPrimaryQlClass() { result = "TypeAccess" }
}