From 6a86f1a91b0b10361819ed835463d7cad977c200 Mon Sep 17 00:00:00 2001 From: Ian Lynagh Date: Tue, 24 Aug 2021 13:03:24 +0100 Subject: [PATCH] Add getPrimaryQlClasses() This is a non-overridable predicate that concatenates all the getAPrimaryQlClass() results into a comma-separated string. --- change-notes/2021-08-23-getPrimaryQlClasses.md | 2 ++ ql/src/semmle/go/AST.qll | 5 +++++ 2 files changed, 7 insertions(+) create mode 100644 change-notes/2021-08-23-getPrimaryQlClasses.md diff --git a/change-notes/2021-08-23-getPrimaryQlClasses.md b/change-notes/2021-08-23-getPrimaryQlClasses.md new file mode 100644 index 00000000000..30b00908a23 --- /dev/null +++ b/change-notes/2021-08-23-getPrimaryQlClasses.md @@ -0,0 +1,2 @@ +lgtm,codescanning +* Added `AstNode.getPrimaryQlClasses()` predicate, which gets a comma-separated list of the names of the primary CodeQL classes to which this element belongs. diff --git a/ql/src/semmle/go/AST.qll b/ql/src/semmle/go/AST.qll index 8468fba1276..6ce205aefae 100644 --- a/ql/src/semmle/go/AST.qll +++ b/ql/src/semmle/go/AST.qll @@ -81,6 +81,11 @@ class AstNode extends @node, Locatable { /** Gets the innermost function definition to which this AST node belongs, if any. */ FuncDef getEnclosingFunction() { result = getParent().parentInSameFunction*() } + /** + * 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 node belongs. *