|
| 1 | +/** |
| 2 | + * @name Print CFG |
| 3 | + * @description Produces a representation of a file's Control Flow Graph. |
| 4 | + * This query is used by the VS Code extension. |
| 5 | + * @id cs/print-cfg |
| 6 | + * @kind graph |
| 7 | + * @tags ide-contextual-queries/print-cfg |
| 8 | + */ |
| 9 | + |
| 10 | +private import semmle.code.csharp.controlflow.internal.ControlFlowGraphImpl |
| 11 | + |
| 12 | +external string selectedSourceFile(); |
| 13 | + |
| 14 | +private predicate selectedSourceFileAlias = selectedSourceFile/0; |
| 15 | + |
| 16 | +external int selectedSourceLine(); |
| 17 | + |
| 18 | +private predicate selectedSourceLineAlias = selectedSourceLine/0; |
| 19 | + |
| 20 | +external int selectedSourceColumn(); |
| 21 | + |
| 22 | +private predicate selectedSourceColumnAlias = selectedSourceColumn/0; |
| 23 | + |
| 24 | +module ViewCfgQueryInput implements ViewCfgQueryInputSig<File> { |
| 25 | + predicate selectedSourceFile = selectedSourceFileAlias/0; |
| 26 | + |
| 27 | + predicate selectedSourceLine = selectedSourceLineAlias/0; |
| 28 | + |
| 29 | + predicate selectedSourceColumn = selectedSourceColumnAlias/0; |
| 30 | + |
| 31 | + predicate cfgScopeSpan( |
| 32 | + CfgScope scope, File file, int startLine, int startColumn, int endLine, int endColumn |
| 33 | + ) { |
| 34 | + file = scope.getFile() and |
| 35 | + scope.getLocation().getStartLine() = startLine and |
| 36 | + scope.getLocation().getStartColumn() = startColumn and |
| 37 | + exists(Location loc | |
| 38 | + loc.getEndLine() = endLine and |
| 39 | + loc.getEndColumn() = endColumn |
| 40 | + | |
| 41 | + loc = scope.(Callable).getBody().getLocation() |
| 42 | + or |
| 43 | + loc = scope.(Field).getInitializer().getLocation() |
| 44 | + or |
| 45 | + loc = scope.(Property).getInitializer().getLocation() |
| 46 | + ) |
| 47 | + } |
| 48 | +} |
| 49 | + |
| 50 | +import ViewCfgQuery<File, ViewCfgQueryInput> |
0 commit comments