Skip to content

Commit 43355fe

Browse files
authored
Merge pull request github#6536 from github/igfoo/getPrimaryQlClasses
All languages: Add getPrimaryQlClasses()
2 parents bc99947 + 1e06808 commit 43355fe

File tree

13 files changed

+34
-6
lines changed

13 files changed

+34
-6
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
lgtm,codescanning
2+
* Added `Element.getPrimaryQlClasses()` predicate, which gets a comma-separated list of the names of the primary CodeQL classes to which this element belongs.

cpp/ql/lib/semmle/code/cpp/Element.qll

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,11 @@ class ElementBase extends @element {
5858
/** DEPRECATED: use `getAPrimaryQlClass` instead. */
5959
deprecated string getCanonicalQLClass() { result = this.getAPrimaryQlClass() }
6060

61+
/**
62+
* Gets a comma-separated list of the names of the primary CodeQL classes to which this element belongs.
63+
*/
64+
final string getPrimaryQlClasses() { result = concat(getAPrimaryQlClass(), ",") }
65+
6166
/**
6267
* Gets the name of a primary CodeQL class to which this element belongs.
6368
*
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
lgtm,codescanning
2+
* Added `Element.getPrimaryQlClasses()` predicate, which gets a comma-separated list of the names of the primary CodeQL classes to which this element belongs.

csharp/ql/lib/semmle/code/cil/ConsistencyChecks.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -670,7 +670,7 @@ class MissingCilDeclaration extends ConsistencyViolation, MissingCSharpCheck {
670670
override string getMessage() {
671671
result =
672672
"Cannot locate CIL for " + getDeclaration().toStringWithTypes() + " of class " +
673-
getDeclaration().getAPrimaryQlClass()
673+
getDeclaration().getPrimaryQlClasses()
674674
}
675675

676676
override string toString() { result = getDeclaration().toStringWithTypes() }

csharp/ql/lib/semmle/code/csharp/PrintAst.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ private predicate isNotNeeded(Element e) {
6161
* Retrieves the canonical QL class(es) for entity `el`
6262
*/
6363
private string getQlClass(Element el) {
64-
result = "[" + concat(el.getAPrimaryQlClass(), ",") + "] "
64+
result = "[" + el.getPrimaryQlClasses() + "] "
6565
// Alternative implementation -- do not delete. It is useful for QL class discovery.
6666
// result = "["+ concat(el.getAQlClass(), ",") + "] "
6767
}

csharp/ql/lib/semmle/code/dotnet/Element.qll

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@ class Element extends @dotnet_element {
4040
/** Gets the full textual representation of this element, including type information. */
4141
string toStringWithTypes() { result = this.toString() }
4242

43+
/**
44+
* Gets a comma-separated list of the names of the primary CodeQL classes to which this element belongs.
45+
*/
46+
final string getPrimaryQlClasses() { result = concat(getAPrimaryQlClass(), ",") }
47+
4348
/**
4449
* Gets the name of a primary CodeQL class to which this element belongs.
4550
*

csharp/ql/test/library-tests/generics/ConsistencyChecks.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ import semmle.code.csharp.commons.ConsistencyChecks
66

77
from Element e, string m
88
where consistencyFailure(e, m)
9-
select e, "Element class " + e.getAPrimaryQlClass() + " has consistency check failed: " + m
9+
select e, "Element class " + e.getPrimaryQlClasses() + " has consistency check failed: " + m
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
lgtm,codescanning
2+
* Added `Top.getPrimaryQlClasses()` predicate, which gets a comma-separated list of the names of the primary CodeQL classes to which this element belongs.

java/ql/lib/semmle/code/Location.qll

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,11 @@ class Top extends @top {
100100
cached
101101
string toString() { hasName(this, result) }
102102

103+
/**
104+
* Gets a comma-separated list of the names of the primary CodeQL classes to which this element belongs.
105+
*/
106+
final string getPrimaryQlClasses() { result = concat(getAPrimaryQlClass(), ",") }
107+
103108
/**
104109
* Gets the name of a primary CodeQL class to which this element belongs.
105110
*

java/ql/lib/semmle/code/java/PrintAst.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ private predicate duplicateMetadata(Field f) {
8989
* Retrieves the canonical QL class(es) for entity `el`
9090
*/
9191
private string getQlClass(Top el) {
92-
result = "[" + concat(el.getAPrimaryQlClass(), ",") + "] "
92+
result = "[" + el.getPrimaryQlClasses() + "] "
9393
// Alternative implementation -- do not delete. It is useful for QL class discovery.
9494
// result = "[" + concat(el.getAQlClass(), ",") + "] "
9595
}

0 commit comments

Comments
 (0)