Merge pull request #13025 from cklin/java-location-tostring-bindingset

Java: Add pragma[only_bind_out] to Top::toString() calls
This commit is contained in:
Chuan-kai Lin
2023-05-08 06:27:42 -07:00
committed by GitHub
4 changed files with 19 additions and 9 deletions

View File

@@ -26,7 +26,7 @@ class Exception extends Element, @exception {
/** Holds if this exception has the specified `name`. */
override predicate hasName(string name) { this.getType().hasName(name) }
override string toString() { result = this.getType().toString() }
override string toString() { result = pragma[only_bind_out](this.getType()).toString() }
override string getAPrimaryQlClass() { result = "Exception" }
}

View File

@@ -1644,7 +1644,9 @@ class TypeLiteral extends Expr, @typeliteral {
Type getReferencedType() { result = this.getTypeName().getType() }
/** Gets a printable representation of this expression. */
override string toString() { result = this.getTypeName().toString() + ".class" }
override string toString() {
result = pragma[only_bind_out](this.getTypeName()).toString() + ".class"
}
override string getAPrimaryQlClass() { result = "TypeLiteral" }
}
@@ -1752,7 +1754,7 @@ class VarAccess extends Expr, @varaccess {
exists(Expr q | q = this.getQualifier() |
if q.isParenthesized()
then result = "(...)." + this.getVariable().getName()
else result = q.toString() + "." + this.getVariable().getName()
else result = pragma[only_bind_out](q).toString() + "." + this.getVariable().getName()
)
or
not this.hasQualifier() and result = this.getVariable().getName()

View File

@@ -27,7 +27,9 @@ class ImportType extends Import {
/** Gets the imported type. */
ClassOrInterface getImportedType() { imports(this, result, _, _) }
override string toString() { result = "import " + this.getImportedType().toString() }
override string toString() {
result = "import " + pragma[only_bind_out](this.getImportedType()).toString()
}
override string getAPrimaryQlClass() { result = "ImportType" }
}
@@ -49,7 +51,9 @@ class ImportOnDemandFromType extends Import {
/** Gets an imported type. */
NestedType getAnImport() { result.getEnclosingType() = this.getTypeHoldingImport() }
override string toString() { result = "import " + this.getTypeHoldingImport().toString() + ".*" }
override string toString() {
result = "import " + pragma[only_bind_out](this.getTypeHoldingImport()).toString() + ".*"
}
override string getAPrimaryQlClass() { result = "ImportOnDemandFromType" }
}
@@ -71,7 +75,7 @@ class ImportOnDemandFromPackage extends Import {
/** Gets a printable representation of this import declaration. */
override string toString() {
result = "import " + this.getPackageHoldingImport().toString() + ".*"
result = "import " + pragma[only_bind_out](this.getPackageHoldingImport()).toString() + ".*"
}
override string getAPrimaryQlClass() { result = "ImportOnDemandFromPackage" }
@@ -100,7 +104,7 @@ class ImportStaticOnDemand extends Import {
/** Gets a printable representation of this import declaration. */
override string toString() {
result = "import static " + this.getTypeHoldingImport().toString() + ".*"
result = "import static " + pragma[only_bind_out](this.getTypeHoldingImport()).toString() + ".*"
}
override string getAPrimaryQlClass() { result = "ImportStaticOnDemand" }
@@ -141,7 +145,9 @@ class ImportStaticTypeMember extends Import {
/** Gets a printable representation of this import declaration. */
override string toString() {
result = "import static " + this.getTypeHoldingImport().toString() + "." + this.getName()
result =
"import static " + pragma[only_bind_out](this.getTypeHoldingImport()).toString() + "." +
this.getName()
}
override string getAPrimaryQlClass() { result = "ImportStaticTypeMember" }

View File

@@ -804,7 +804,9 @@ class AnonymousClass extends NestedClass {
// Include super.toString, i.e. the name given in the database, because for Kotlin anonymous
// classes we can get specialisations of anonymous generic types, and this will supply the
// trailing type arguments.
result = "new " + this.getClassInstanceExpr().getTypeName() + "(...) { ... }" + super.toString()
result =
"new " + pragma[only_bind_out](this.getClassInstanceExpr().getTypeName()).toString() +
"(...) { ... }" + super.toString()
}
/**