|
7 | 7 | * @tags ide-contextual-queries/print-cfg |
8 | 8 | */ |
9 | 9 |
|
10 | | - private import codeql.actions.Cfg |
11 | | - private import codeql.actions.Cfg::TestOutput |
12 | | - private import codeql.actions.ideContextual.IDEContextual |
13 | | - private import codeql.Locations |
14 | | - |
15 | | - /** |
16 | | - * Gets the source file to generate a CFG from. |
17 | | - */ |
18 | | - external string selectedSourceFile(); |
19 | | - |
20 | | - external string selectedSourceLine(); |
21 | | - |
22 | | - external string selectedSourceColumn(); |
23 | | - |
24 | | - bindingset[file, line, column] |
25 | | - private CfgScope smallestEnclosingScope(File file, int line, int column) { |
26 | | - result = |
27 | | - min(Location loc, CfgScope scope | |
28 | | - loc = scope.getLocation() and |
29 | | - ( |
30 | | - loc.getStartLine() < line |
31 | | - or |
32 | | - loc.getStartLine() = line and loc.getStartColumn() <= column |
33 | | - ) and |
34 | | - ( |
35 | | - loc.getEndLine() > line |
36 | | - or |
37 | | - loc.getEndLine() = line and loc.getEndColumn() >= column |
38 | | - ) and |
39 | | - loc.getFile() = file |
40 | | - | |
41 | | - scope |
42 | | - order by |
43 | | - loc.getStartLine() desc, loc.getStartColumn() desc, loc.getEndLine(), loc.getEndColumn() |
44 | | - ) |
45 | | - } |
46 | | - |
47 | | - class MyRelevantNode extends RelevantNode { |
48 | | - MyRelevantNode() { |
49 | | - this.getScope() = |
50 | | - smallestEnclosingScope(getFileBySourceArchiveName(selectedSourceFile()), |
51 | | - selectedSourceLine().toInt(), selectedSourceColumn().toInt()) |
52 | | - } |
53 | | - } |
| 10 | +private import codeql.actions.Cfg |
| 11 | +private import codeql.actions.Cfg::TestOutput |
| 12 | +private import codeql.actions.ideContextual.IDEContextual |
| 13 | +private import codeql.Locations |
| 14 | + |
| 15 | +/** |
| 16 | + * Gets the source file to generate a CFG from. |
| 17 | + */ |
| 18 | +external string selectedSourceFile(); |
| 19 | + |
| 20 | +external string selectedSourceLine(); |
| 21 | + |
| 22 | +external string selectedSourceColumn(); |
| 23 | + |
| 24 | +bindingset[file, line, column] |
| 25 | +private CfgScope smallestEnclosingScope(File file, int line, int column) { |
| 26 | + result = |
| 27 | + min(Location loc, CfgScope scope | |
| 28 | + loc = scope.getLocation() and |
| 29 | + ( |
| 30 | + loc.getStartLine() < line |
| 31 | + or |
| 32 | + loc.getStartLine() = line and loc.getStartColumn() <= column |
| 33 | + ) and |
| 34 | + ( |
| 35 | + loc.getEndLine() > line |
| 36 | + or |
| 37 | + loc.getEndLine() = line and loc.getEndColumn() >= column |
| 38 | + ) and |
| 39 | + loc.getFile() = file |
| 40 | + | |
| 41 | + scope |
| 42 | + order by |
| 43 | + loc.getStartLine() desc, loc.getStartColumn() desc, loc.getEndLine(), loc.getEndColumn() |
| 44 | + ) |
| 45 | +} |
| 46 | + |
| 47 | +class MyRelevantNode extends RelevantNode { |
| 48 | + MyRelevantNode() { |
| 49 | + this.getScope() = |
| 50 | + smallestEnclosingScope(getFileBySourceArchiveName(selectedSourceFile()), |
| 51 | + selectedSourceLine().toInt(), selectedSourceColumn().toInt()) |
| 52 | + } |
| 53 | +} |
0 commit comments