Files
codeql/csharp/ql/lib/printAst.ql
2025-09-01 14:57:30 +02:00

29 lines
771 B
Plaintext

/**
* @name Print AST
* @description Outputs a representation of a file's Abstract Syntax Tree. This
* query is used by the VS Code extension.
* @id cs/print-ast
* @kind graph
* @tags ide-contextual-queries/print-ast
*/
import csharp
import semmle.code.csharp.PrintAst
import definitions
/**
* The source file to generate an AST from.
*/
external string selectedSourceFile();
class PrintAstConfigurationOverride extends PrintAstConfiguration {
/**
* Holds if the location `l` matches the selected file in the VS Code extension and
* the element is `e` is `fromSource`.
*/
override predicate shouldPrint(Element e, Location l) {
super.shouldPrint(e, l) and
l.getFile() = getFileBySourceArchiveName(selectedSourceFile())
}
}