mirror of
https://github.com/github/codeql.git
synced 2026-01-30 14:52:57 +01:00
This means it's no longer possible to ask for the AST of a function literal, but this is hopefully a niche use-case that we can add if and when there is demand.
29 lines
753 B
Plaintext
29 lines
753 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 go/print-ast
|
|
* @kind graph
|
|
* @tags ide-contextual-queries/print-ast
|
|
*/
|
|
|
|
import go
|
|
import semmle.go.PrintAst
|
|
import ideContextual
|
|
|
|
/**
|
|
* The source file to generate an AST from.
|
|
*/
|
|
external string selectedSourceFile();
|
|
|
|
/**
|
|
* Hook to customize the functions printed by this query.
|
|
*/
|
|
class Cfg extends PrintAstConfiguration {
|
|
override predicate shouldPrintFunction(FuncDecl func) { shouldPrintFile(func.getFile()) }
|
|
|
|
override predicate shouldPrintFile(File file) { file = getEncodedFile(selectedSourceFile()) }
|
|
|
|
override predicate shouldPrintComments(File file) { none() }
|
|
}
|