mirror of
https://github.com/github/codeql.git
synced 2025-12-17 01:03:14 +01:00
All languages: Add getPrimaryQlClasses()
This is a non-overridable predicate that concatenates all the getAPrimaryQlClass() results into a comma-separated string.
This commit is contained in:
2
cpp/change-notes/2021-08-23-getPrimaryQlClasses.md
Normal file
2
cpp/change-notes/2021-08-23-getPrimaryQlClasses.md
Normal file
@@ -0,0 +1,2 @@
|
||||
lgtm,codescanning
|
||||
* Added `ElementBase.getPrimaryQlClasses()` predicate, which gets a comma-separated list of the names of the primary CodeQL classes to which this element belongs.
|
||||
@@ -58,6 +58,11 @@ class ElementBase extends @element {
|
||||
/** DEPRECATED: use `getAPrimaryQlClass` instead. */
|
||||
deprecated string getCanonicalQLClass() { result = this.getAPrimaryQlClass() }
|
||||
|
||||
/**
|
||||
* Gets a comma-separated list of the names of the primary CodeQL classes to which this element belongs.
|
||||
*/
|
||||
final string getPrimaryQlClasses() { result = concat(getAPrimaryQlClass(), ",") }
|
||||
|
||||
/**
|
||||
* Gets the name of a primary CodeQL class to which this element belongs.
|
||||
*
|
||||
|
||||
2
csharp/change-notes/2021-08-23-getPrimaryQlClasses.md
Normal file
2
csharp/change-notes/2021-08-23-getPrimaryQlClasses.md
Normal file
@@ -0,0 +1,2 @@
|
||||
lgtm,codescanning
|
||||
* Added `Element.getPrimaryQlClasses()` predicate, which gets a comma-separated list of the names of the primary CodeQL classes to which this element belongs.
|
||||
@@ -670,7 +670,7 @@ class MissingCilDeclaration extends ConsistencyViolation, MissingCSharpCheck {
|
||||
override string getMessage() {
|
||||
result =
|
||||
"Cannot locate CIL for " + getDeclaration().toStringWithTypes() + " of class " +
|
||||
getDeclaration().getAPrimaryQlClass()
|
||||
getDeclaration().getPrimaryQlClasses()
|
||||
}
|
||||
|
||||
override string toString() { result = getDeclaration().toStringWithTypes() }
|
||||
|
||||
@@ -61,7 +61,7 @@ private predicate isNotNeeded(Element e) {
|
||||
* Retrieves the canonical QL class(es) for entity `el`
|
||||
*/
|
||||
private string getQlClass(Element el) {
|
||||
result = "[" + concat(el.getAPrimaryQlClass(), ",") + "] "
|
||||
result = "[" + el.getPrimaryQlClasses() + "] "
|
||||
// Alternative implementation -- do not delete. It is useful for QL class discovery.
|
||||
// result = "["+ concat(el.getAQlClass(), ",") + "] "
|
||||
}
|
||||
|
||||
@@ -40,6 +40,11 @@ class Element extends @dotnet_element {
|
||||
/** Gets the full textual representation of this element, including type information. */
|
||||
string toStringWithTypes() { result = this.toString() }
|
||||
|
||||
/**
|
||||
* Gets a comma-separated list of the names of the primary CodeQL classes to which this element belongs.
|
||||
*/
|
||||
final string getPrimaryQlClasses() { result = concat(getAPrimaryQlClass(), ",") }
|
||||
|
||||
/**
|
||||
* Gets the name of a primary CodeQL class to which this element belongs.
|
||||
*
|
||||
|
||||
@@ -6,4 +6,4 @@ import semmle.code.csharp.commons.ConsistencyChecks
|
||||
|
||||
from Element e, string m
|
||||
where consistencyFailure(e, m)
|
||||
select e, "Element class " + e.getAPrimaryQlClass() + " has consistency check failed: " + m
|
||||
select e, "Element class " + e.getPrimaryQlClasses() + " has consistency check failed: " + m
|
||||
|
||||
2
java/change-notes/2021-08-23-getPrimaryQlClasses.md
Normal file
2
java/change-notes/2021-08-23-getPrimaryQlClasses.md
Normal file
@@ -0,0 +1,2 @@
|
||||
lgtm,codescanning
|
||||
* Added `Top.getPrimaryQlClasses()` predicate, which gets a comma-separated list of the names of the primary CodeQL classes to which this element belongs.
|
||||
@@ -100,6 +100,11 @@ class Top extends @top {
|
||||
cached
|
||||
string toString() { hasName(this, result) }
|
||||
|
||||
/**
|
||||
* Gets a comma-separated list of the names of the primary CodeQL classes to which this element belongs.
|
||||
*/
|
||||
final string getPrimaryQlClasses() { result = concat(getAPrimaryQlClass(), ",") }
|
||||
|
||||
/**
|
||||
* Gets the name of a primary CodeQL class to which this element belongs.
|
||||
*
|
||||
|
||||
@@ -89,7 +89,7 @@ private predicate duplicateMetadata(Field f) {
|
||||
* Retrieves the canonical QL class(es) for entity `el`
|
||||
*/
|
||||
private string getQlClass(Top el) {
|
||||
result = "[" + concat(el.getAPrimaryQlClass(), ",") + "] "
|
||||
result = "[" + el.getPrimaryQlClasses() + "] "
|
||||
// Alternative implementation -- do not delete. It is useful for QL class discovery.
|
||||
// result = "[" + concat(el.getAQlClass(), ",") + "] "
|
||||
}
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
lgtm,codescanning
|
||||
* Added `Locatable.getPrimaryQlClasses()` predicate, which gets a comma-separated list of the names of the primary CodeQL classes to which this element belongs.
|
||||
@@ -132,6 +132,11 @@ class Locatable extends @locatable {
|
||||
none()
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a comma-separated list of the names of the primary CodeQL classes to which this element belongs.
|
||||
*/
|
||||
final string getPrimaryQlClasses() { result = concat(getAPrimaryQlClass(), ",") }
|
||||
|
||||
/**
|
||||
* Gets the primary QL class for the Locatable.
|
||||
*/
|
||||
|
||||
@@ -44,9 +44,9 @@ private predicate isNotNeeded(Locatable el) {
|
||||
* Retrieves the canonical QL class(es) for entity `el`
|
||||
*/
|
||||
private string getQlClass(Locatable el) {
|
||||
result = "[" + concat(el.getAPrimaryQlClass(), ",") + "] "
|
||||
result = "[" + el.getPrimaryQlClasses() + "] "
|
||||
// Alternative implementation -- do not delete. It is useful for QL class discovery.
|
||||
// not el.getAPrimaryQlClass() = "???" and result = "[" + concat(el.getAPrimaryQlClass(), ",") + "] " or el.getAPrimaryQlClass() = "???" and result = "??[" + concat(el.getAQlClass(), ",") + "] "
|
||||
// not el.getAPrimaryQlClass() = "???" and result = "[" + getPrimaryQlClasses() + "] " or el.getAPrimaryQlClass() = "???" and result = "??[" + concat(el.getAQlClass(), ",") + "] "
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user