-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathPrintAST.ql
More file actions
46 lines (44 loc) · 1.37 KB
/
PrintAST.ql
File metadata and controls
46 lines (44 loc) · 1.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/**
* @name Print AST for actions
* @description Outputs a representation of the Abstract Syntax Tree.
* @id actions/tools/print-ast
* @kind graph
* @tags ast
*/
private import codeql.actions.ideContextual.IDEContextual
import codeql.actions.ideContextual.printAst
private import codeql.actions.Ast
/**
* Temporarily tweak this class or make a copy to control
* which functions are printed.
*/
class Cfg extends PrintAstConfiguration {
/**
* TWEAK THIS PREDICATE AS NEEDED.
*/
override predicate shouldPrintNode(PrintAstNode n) {
super.shouldPrintNode(n) and
// Only include source files with a `test` directory as the parent
// of its containing directory, which fits the expected structure
// of CodeQL unit tests in this project.
(
// For a file located under some `test/*/.github/worklows` directory structure
n.getLocation()
.getFile()
.getParentContainer()
.getParentContainer()
.getParentContainer()
.getParentContainer()
.getBaseName() = "test"
or
// For a file located under some `test/*/*/action.yml` directory structure
n.getLocation()
.getFile()
.getParentContainer()
.getParentContainer()
.getParentContainer()
.getBaseName() = "test" and
n.getLocation().getFile().getBaseName() = "action.yml"
)
}
}